In my script for when my player dies any time I use a variable in a function it Errors out and causes my entire script to stop working like this
local human = character:FindFirstChild("Humanoid") human.Changed:connect(function(death) if human.Health == 0 then
then I get this http://gyazo.com/506bf5c20756e130e337ccb3e5f7bf7c <-- picture
the script works completely correct in play solo just not online
Try using WaitForChild
instead of FindFirstChild
. If FindFirstChild
doesn't return the humanoid, it will cause an error as shown in your script, where as WaitForChild
will wait until the child is available.
Also, I recommend using the Died event instead of waiting for the health to change. (Unless you need it to check for the health to be changed for some reason. In that case, ignore what I said.)
local human = character:WaitForChild("Humanoid") human.Died:connect(function() --Enter code here end)