Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.