I want to kill a player once as soon as they join. Here is my code:
game.Players.PlayerAdded:connect(function(player) game.Players.PlayerAdded:connect(function(player) --Waits for player player.CharacterAdded:connect(function(char) --Waits for character wait() --Waits so they can kill char:WaitForChild("ForceField"):Destroy() --Destroys ForceField char:WaitForChild("Humanoid").Health=0 --Sets Health to zero end) end) end)
I do not understand why this is working. Can someone help?
You checked for the player being added twice. I changed this so you don't have to use character added, if you used CharacterAdded, then it would kill the player every time you spawned. WaitForChild will wait until the player is loaded into the game. Destroying the Torso will not make you have to remove the ForceField.
game.Players.PlayerAdded:connect(function(player) local char = workspace:WaitForChild(player.Name) char:WaitForChild("Torso"):Destroy() end)