0

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

Edited 4 years ago

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)


0
Thats because youre trying to change the text of the frame which doesnt exist TheOwlFromSaturn 26 — 4y
0
According to your first image, You should add after the 3rd parent in line 10, NumHealth mixgingengerina10 223 — 4y

0
Edited 4 years ago

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)


0
NumHealth is not a child of Goblin[level 2] I believe mixgingengerina10 223 — 4y
script.Parent.Parent.Parent.Parent.NumHealth.Text = tostring(human.Health).."/"..tostring(human.MaxHealth)