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

The Healthnumber on my Healthbar isn't decreasing, but the healthbar itself works properly?

So I've created a healthbar and it works fine. I have added a "NumHealth" which shows how much HP you have left, example = 100/100HP, and when the mob hits you for 5 damage, it will show 95/100 HP, but I simply can't get that to work. I just get the error: Text is not a valid member of Frame (Error is on line 10)

local human = script.Parent.Parent.Parent.Parent.Parent.Parent.Human
local health = human.Health
local maxhealth = human.MaxHealth

human.Changed:connect(function(health)

if health then

script.Parent:TweenSize(UDim2.new(human.Health/human.MaxHealth, 0, 1, 0))
script.Parent.Parent.Parent.Text = tostring(human.Health).."/"..tostring(human.MaxHealth)

end

end)

Image1 Image2

2 comments

0

Thats because youre trying to change the text of the frame which doesnt exist

0

According to your first image, You should add after the 3rd parent in line 10, NumHealth

2 answers

✓ Accepted answer

from what I understand from the image you posted you should do


script.Parent.Parent.Parent.Parent.Parent.Parent.NumHealth.Text = tostring(human.Health).."/"..tostring(human.MaxHealth)

1 comment

0

NumHealth is not a child of Goblin[level 2] I believe

Alright, I found the mistake, thanks for the help!

script.Parent.Parent.Parent.Parent.NumHealth.Text = tostring(human.Health).."/"..tostring(human.MaxHealth)

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