My friend asked this to me. He wants to teleport ALL players in the server, to a spesific area on the server. The following code that he has only teleports ONE player.
The code:
while true do wait(1) local m = math.random(1,1) local player = game.Players:GetPlayers() for i = 1, #player do msg = Instance.new("Message") msg.Parent = nil if m == 1 then msg.Parent = game.Workspace -- gets players wait(10) player[i].Character:MoveTo(Vector3.new(297.023, 41.105, 41.83)) msg:remove() wait(60) end wait(5) player[i].Character:MoveTo(Vector3.new(-23.112, 101.5, 38.096)) msg:remove() end end
What's wrong with your script is that it waits 70 seconds before teleporting each player. To fix this, you want to spawn a new thread.
while true do wait(1) local m = math.random(1,1) local player = game.Players:GetPlayers() for i = 1, #player do msg = Instance.new("Message") msg.Parent = nil if m == 1 then spawn(function() msg.Parent = game.Workspace -- gets players wait(10) player[i].Character:MoveTo(Vector3.new(297.023, 41.105, 41.83)) msg:remove() wait(60) end) end wait(5) player[i].Character:MoveTo(Vector3.new(-23.112, 101.5, 38.096)) msg:remove() end end