✓ Accepted answer
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.
1 comment
Line 1:
Health = script.Parent.HumanoidLine 6if Health.Health > 0 then