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

How do I check if a player reset?

Asked by 6 years ago

This code below is from a script in Workspace and it doesn't seem to work if a player resets.

game.Players.PlayerAdded:connect(function(p)
    wait(1)
    p.Character.Humanoid.Died:connect(function(c)
        print("dead")
        dead = true
    end)
end)
0
is that code running from a server script? abnotaddable 920 — 6y
0
Yes. BennyBoiOriginal 293 — 6y
0
Humanoid.Health <1 Lolamtic 63 — 6y
0
Doesn't work. BennyBoiOriginal 293 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

http://wiki.roblox.com/index.php?title=API:Class/Humanoid/Died

game:GetService('Players').PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()
            print(player.Name .. " has died!")
            -- by setting dead to true you do it for all players i would not reccomend.
        end)
    end)
end)
0
It has to wait for the new character, since the player's appearence regenerates every time it dies. AdministratorReece 193 — 6y
Ad

Answer this question