Can anyone help me create an automatic teleport script? Example; 5 minutes pass - random player - transported to CFrame (-154) Sorry if the example is not explicit. The script literally chooses a random player within 7 minutes and that player is transported Imagine
local Players = game:GetService("Players") local PlaceXYZ = Vector3.new(1, 0, 10) function teleportRandomPlayer() local plrs = Players:GetChildren() local n = math.random(1, #plrs) for i, v in pairs(plrs) do if i == n then if workspace:FindFirstChild(v.Name) then if workspace[v.Name]:FindFirstChild("HumanoidRootPart") then workspace[v.Name].HumanoidRootPart.Position = PlaceXYZ end end break end end end spawn(function() while wait(1000) do teleportRandomPlayer() end end)
I tried this script and it didn't work
Teleports a healthy/alive random player every 7 minutes.
Put the code into a ServerScript, and then you can put the ServerScript into ServerScriptService or the workspace.
local PlayersService = game:GetService("Players") local PlaceXYZ = CFrame.new(1, 0, 10) function TeleportRandomPlayer() local Players = PlayersService:GetChildren() local Chosen = Players[math.random(#Players)] if game.Workspace:FindFirstChild(Chosen.Name) then local ChosenCharacter = game.Workspace:FindFirstChild(Chosen.Name) local ChosenHumanoid = ChosenCharacter:WaitForChild("Humanoid") if ChosenHumanoid.Health > 0 then local ChosenHumanoidRootPart = ChosenCharacter:WaitForChild("HumanoidRootPart") ChosenHumanoidRootPart.CFrame = PlaceXYZ end end end while wait(420) do TeleportRandomPlayer() end