Help with making my teleport players script stop after teleporting players

Hi, I have a script that teleports everybody to an area but after all players are teleported it keeps teleporting all the players to the area here is the script:

while wait(0.01) do
		
	for i,v in pairs(game.Players:GetPlayers()) do
		task.wait(0.01)
		v.Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(710, 35, -102)
	end
	print("Teleported All Players!")
end

First off, why are you using a while loop, second use the break keyword to end/break out of a loop

2 Likes

You don’t have to loop it, but instead have it just be running on it’s own:

for i,v in pairs(game.Players:GetPlayers()) do
		task.wait(0.01)
		v.Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(710, 35, -102)
	end
	print("Teleported All Players!")
1 Like