Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Place this script in ServerScriptService
- local function getOnlinePlayers()
- local onlinePlayers = {}
- for _, player in pairs(game.Players:GetPlayers()) do
- if player and player:IsDescendantOf(game.Workspace) then
- table.insert(onlinePlayers, player)
- end
- end
- return onlinePlayers
- end
- local function bringRandomPlayer(destination)
- local onlinePlayers = getOnlinePlayers()
- if #onlinePlayers > 0 then
- local randomPlayer = onlinePlayers[math.random(1, #onlinePlayers)]
- local character = randomPlayer.Character
- if character then
- local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
- if humanoidRootPart then
- humanoidRootPart.CFrame = destination.CFrame
- end
- end
- else
- warn("No online players found.")
- end
- end
- game.Players.PlayerAdded:Connect(function(player)
- player.Chatted:Connect(function(message)
- if message:lower() == "!bring" then
- local destination = game.Workspace.BringDestination -- Change this to your desired destination
- if destination and destination:IsA("BasePart") then
- bringRandomPlayer(destination)
- else
- warn("Bring destination not found.")
- end
- end
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement