The speed keeps on resetting

I am making a round based game, and every time it starts, it should make the players fast. It kinda works, it is very buggy and the speed resets sometimes once someone dies, but I have no clue why. This is the script I am doing it in.

while wait(1) do

	for i,plr in pairs(game.Players:GetChildren()) do

		local hum = plr.CharacterAdded:Wait().Humanoid
		if plr.Team == game.Teams.Playing then
			if plr:FindFirstChild("SpeedActive").Value == false then
				hum.WalkSpeed = 30
			end
		else if plr.Team == game.Teams.Lobby then
				hum.WalkSpeed = 16
			end
			end
	end
	end

speed active is for something else, if you think that is the problem then ask what it is, but I dont think it is the problem. Im guessing there is just a much more beneficent way of doing this.

Are you sure about that player after death is still in Teams.Playing? Check this maybe :slight_smile:

Yes, they are constantly in playing untill they die 3 times, for a lives system.

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local SpeedActive = Player:WaitForChild("SpeedActive")
		local Humanoid = Character:WaitForChild("Humanoid")
		if not SpeedActive or not Humanoid then return end
		Humanoid.WalkSpeed = (SpeedActive.Value and Player.Team == game.Teams.Playing) and 30 or 16
	end)
end)