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

How do I make a "Player died" message?

Asked by 9 years ago

How do I make a message appear when a player dies? ( Sort of like the script below)

game.Players.PlayerAdded:connect(function(plr)
   print(plr.Name.." Has Joined the game")
end)

0
More or less is there a PlayerDied function :) Seeker5123 15 — 9y
0
Do your research, a quick google or wiki search could have gotten you the answer. Perci1 4988 — 9y

1 answer

Log in to vote
2
Answered by 9 years ago

Died

Roblox has an event that fires whenever a Humanoid 'Dies'. It's exactly as it sounds, it's the 'Died' event.

It's fired when the Health Property of a Humanoid reaches 0 or below.


Directly From The Wiki:

Fired after a character's health reaches 0. Which could be caused either by disconnecting their head from their torso, or directly setting the health property.


You have to bind the event to the Characters Humanoid in order for it to work.

Here is an example of it in code:

game.PlayersPlayerAdded:connect(function(plr)
 print(plr.Name .. " has joined the game!")
    plr.CharacterAdded:connect(function(chr)
        chr:WaitForChild("Humanoid").Died:connect(function()
            print(plr.Name .. " has died!")
        end)
    end)
end)

Link

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

0
Awesome, thanks :) Seeker5123 15 — 9y
Ad

Answer this question