✓ Accepted answer
Use the .Died event! It is fired after a character has entered the dead state, usually when their health reaches 0. Nonetheless, your player variable is a table of players, which wouldn't work!
Just got the following code from this wiki article.
You'll want to put this in a script in ServerScriptStorage. Since we're using a ServerSide script, it can at times be difficult to define the player....As such, a quick and efficient way to accomplish such a task would be to use both the playeradded event and the characteradded event to then be able to link to the players humanoid (The .Died event fires off of the humanoid) .
game:GetService('Players').PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()
print(player.Name .. " has died!")
end)
end)
end)
3 comments
I tried simplifying this so it'll work in an ifelse statement, but it told me 'Character' is a nil value. Should I post what I did?
For sure. Edit your post and put your new code in
I figured it out, thanks for the help.