So i am trying to get this script to call a function when the humanoids health is at "0" but when i run it, it doesn't do anything even though the function is a simple "print Word" into the output, why is it not working?
if script.Parent.Humanoid.Health == 0 then PrintWord() end function PrintWord() print 'Hello world!' end
Pyrondon's script will work, but it's not as simple as you could make it. Instead of using two functions you only have to use one. Here's what you could do much more easily,
script.Parent.Humanoid.Changed:connect(function(health)--Health is the propertie that changed. It also makes a variable that we use below. if health == 0 then Print"Hello World!" --do what you were doing in your function here. end end)
This is just simplified. If you like having two functions that's up to you and you should use Pyrondon's script. Hope I helped!
In the future, please be more descriptive about your problem in the title.
Your problem is that the script only checks once. You can fix this by connecting a function to the .Changed event.
function PrintWord() print 'Hello world!' end script.Parent.Humanoid.Changed:connect(function() if script.Parent.Humanoid.Health == 0 then PrintWord() end end)
Please excuse any grammatical errors I may have made; I am mobile right now.
Hope this helped.