I keep trying this but it doesn't work. What happens instead is it auto prints "dead" even when the brick has 1000 health.
a = script.Parent
if a.Humanoid.Health==0
then
print "dead"
I keep trying this but it doesn't work. What happens instead is it auto prints "dead" even when the brick has 1000 health.
a = script.Parent
if a.Humanoid.Health==0
then
print "dead"
I presume that you have a Humanoid in your brick. If so then create a loop checking the if statement if its health is either 0 or less than 0.
a = script.Parent
while true do
wait(1)
if a.Humanoid.Health <=0
then
print "dead"
end
end
All Humanoids have the event called the Died Event. The event fires when the Humanoid's health gets below 1.
You could have found this event on the wiki about Humanoids and looking at their events.
Assuming a is the Humanoid...
local a = script.Parent:WaitForChild("Humanoid")
a.Died:connect(function()
print("Died")
end)
Good Luck!
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Try to avoid loops.