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

why is this script giving me an error?

It says "attempted to index 'Health' (a number value)" and I do not know what to do to get rid of this error. Basically I am trying to display the characters health on a local gui.

local player = script.Parent.Parent.Parent.Parent.Parent.Parent

player.Character.Humanoid.Health.Changed:connect(function(health)
	script.Parent.Text = health.."%"
end)

1 answer

I didn't see where you defined health. You need to either declare health or point to The proper location.

Try changing health(where you set the text) to

player.Character:FindFirstChild("Humanoid").Health

Sorry if I got anything wrong I am using a phone with spell correction.

3 comments

0

I just notices you used health as a param. I don't think that is a param. I could be wrong though

0

it works when I print it, if i say print(player.Character.Humanoid.Health) it will print my health

0

Try using player.Character.Humanoid.Health then.

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