Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 6 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)

Image1 Image2

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

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 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 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

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

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

Answer this question