This script is supposed to get 1 random player out of the players service and teleport him when he/ she is chosen.
players = game.Players:GetChildren()
while true do wait() playerchose = math.random(1,#players) playerchosen = players[playerchose] playerchosen.Character.Torso.CFrame = CFrame.new(Vector3.new(10,10,10)) wait(2) end end
You have two end
s at the end. If you remove one of them it should work. Make sure to check if there is at least one player though, otherwise it might error. With that check in there, you do need two ends after all.
players = game.Players:GetChildren() while true do wait() if #players > 0 then playerchose = math.random(1,#players) playerchosen = players[playerchose] playerchosen.Character.Torso.CFrame = CFrame.new(Vector3.new(10,10,10)) wait(2) end end