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

How do I detect if a humainoid health is at 0?

I am making a zombie game where if you shoot the zombies and kill them you get money. But in this case my script isn't working, can anyone help please? Thanks!

game.Players.PlayerAdded:connect(function()
	local Zombie = game.ServerStorage.Zombie
	
	local player = script.Parent.Parent
	local leaderboard = player:WaitForChild("leaderstats")
	local money = leaderboard:WaitForChild("Money")
	
	Zombie:WaitForChild("Humanoid").Died:connect(function()
		money.Value = money.Value + 100
	end)
end)

2 comments

0

On line two it is stored in Server Storage for another script purpose. So no worries for that line

0

Line two is where the Zombies will get cloned into workspace

1 answer

It isn't a great way to use waitforchild in line 8 Try this.

local humanoid = Zombie:WaitForChild("Humanoid")
    repeat until wait() humanoid.Health = 0
      money.Value = money.Value+100

Replace line 8 to 10 with this script.

If it still not working, try to search your error online.

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