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

What is the function to connect a death?

Asked by 10 years ago

Is it

function ConnectOnDeath()

I'm stuck in writing the code I'm doing. It makes a number in the GUI go down when you die.

2 answers

Log in to vote
0
Answered by
TofuBytes 500 Moderation Voter
10 years ago

This should help. You need to indicate what ConnectOnDeath() is.

local player = game.Players.LocalPlayer

function ConnectOnDeath()
--Rest of Script
if player.Character.Humanoid.Health == 0 then
ConnectOnDeath()
end
Ad
Log in to vote
0
Answered by 10 years ago

Here you go. Because your question wasn't very detailed this is the best i could get out of it.

This event triggers when a player dies.

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)

Article: http://wiki.roblox.com/index.php?title=Died

Answer this question