Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why am I getting this Health error?

This is in a normal script in the StarterGui Any ideas why I am getting this error?

attempt to index field 'Health' (a number value)

Code:

script.Parent.Parent.Character.Humanoid.Health.Changed:connect(function()
if script.Parent.Parent.Character.Humanoid.Health == 0 then 
script.Parent.Parent.TeamColor = script.Col.Value 
script:Destroy()
end
end)




I hadn't had any problems with it up until recently :/

1 answer

The Changed event is a part of the Humanoid, not of it's Health property.

Fix:

script.Parent.Parent.Character.Humanoid.Changed:connect(function()
	if script.Parent.Parent.Character.Humanoid.Health == 0 then 
		script.Parent.Parent.TeamColor = script.Col.Value 
		script:Destroy()
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.