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

How can you check if Player's health reaches 0?

Asked by
AyeJude 41
6 years ago

Hi. I managed to disable Player died function, because I want to play animations after the player dies. I understand the "Changed" event, but I don't really know I would implement it in something like this. Is there anything you can tell or show me, so I can go into the right direction? Any help would be appreciated!

1 answer

Log in to vote
0
Answered by 6 years ago

You can always setup a loop to determine if the Humanoids Health is at 0

localscript in startergui:

repeat wait() until game:GetService("Players").LocalPlayer -- loading player
local Character = workspace:FindFirstChild(game.Players.LocalPlayer.Name) -- get character
while wait() do -- setting up while loop, a forever loop
    if Character:FindFirstChild("Humanoid") then -- making sure character has humanoid
        if Character.Humanoid.Health.Value <= 0 then -- if the players health is less than 0...
            -- Insert what you want
        end
    end
end

So I don't know what you wanna do when the player dies because I don't know if you scripted the animations...

If you need to put the animations somewhere, put it where it says "Insert what you want"

This is not tested by the way so if it doesn't work then, I tried what I could, thanks

Ad

Answer this question