Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to reset all players in a server?

Asked by 4 years ago

I'm making a game with rounds, and at the end of each round all players are reset and then sent back to the lobby. My code below isn't resetting all players and I don't know what is wrong.

local playerstoreset = game.Players:GetChildren() for i = 1, #playerstoreset do if playerstoreset[i]:WaitForChild("Character") ~= nil then playerstoreset[i]:WaitForChild("Character").Humanoid.Health = 0

2 answers

Log in to vote
0
Answered by 4 years ago
for i,v in pairs(game.Players:GetPlayers()) do
v.Character.Humanoid.Health = 0
end
Ad
Log in to vote
0
Answered by 4 years ago

Use the In Pair loop.

Answer this question