Health = script.Parent.Humanoid.Health Head = script.parent.Head Eye1 = script.Parent.Eye1 Eye2 = script.parent.Eye2 if Health > 0 then print("Hello world!") end
Here is the model of the slug that I'm trying to make the script work for, https://www.roblox.com/library/1483332684/Evil-Slug
Your script probably only runs once, that’s why. You can use a loop or function to fix this. Here’s some examples :
Loop :
Health = script.Parent.Humanoid.Health Head = script.parent.Head Eye1 = script.Parent.Eye1 Eye2 = script.parent.Eye2 while wait() do if Health <= 0 then print("Hello world!") end end
Loops will constantly run the code that is in the loop, but that also means it will not run any code under it until the loop ends/breaks.
Function :
Humanoid = script.Parent.Humanoid Head = script.parent.Head Eye1 = script.Parent.Eye1 Eye2 = script.parent.Eye2 Humanoid:GetPropertyChangedSignal(“Health”):Connect(function() if Humanoid.Health <= 0 then print("Hello world!") end
I prefer functions more as code can still run through the functions instead of stalling at it. This function will run once the health property in the humanoid changes.
Hope this helped!
Also why are you using > ? That makes the conditional statement run only if the health is greater than 0 (Ex: 1, 3, 100, etc.). I changed it to < = so the code will run only if the health is below or equal to 0.