Health GUI Problem

I’m working on making a vehicle health GUI and it’s not going to well.
https://gyazo.com/e6bd1606fabc422caec4b9aba42533ce

They should be matching. Here’s the setup for it:
https://gyazo.com/740174ee82b451fc308b8ded45fcbfd3

Here’s the code inside the Main local script:
–//Variables
local speeder = script.Parent.Parent.Parent
local humanoid = speeder.Humanoid
local healthGui = script.Parent
–//Health
humanoid:GetPropertyChangedSignal(“Health”):Connect(function()
local healthColor = Color3.fromRGB(255,0,0):Lerp(Color3.fromRGB(85,255,0),humanoid.Health/humanoid.MaxHealth)
local healthChange = humanoid.Health/humanoid.MaxHealth
healthGui.Health.Meter:TweenSize(UDim2.new(healthChange,0,1,0),“In”,“Linear”,1)
healthGui.Health.Meter.BackgroundColor3 = healthColor
end)

1 Like

Localscripts cannot run in workspace, they must be put in StarterGui/PlayerGui, StarterPack/Backpack, PlayerScripts or the Character

3 Likes

That fixed it, thank you very much!

It’s glitching and I’m not sure what the problem is.
https://gyazo.com/ba65f16f9121ad87f7c7cbdf91db5476
It gets to a certain point and goes straight down to 0.

Not sure if this will fix it but after the length of time in the TweenSize function, you have to add a true which allows it to be overridden if TweenSize is called on the Meter again
healthGui.Health.Meter:TweenSize(UDim2.new(healthChange,0,1,0),“In”,“Linear”,1, true)

1 Like

Didn’t fix it but could it be because I converted it from a player health GUI to the vehicle health bar? The vehicle doesn’t have any scripts yet it’s just got a humanoid and a health bar GUI

Could you give me a file with the code and the BillboardGui. I took the code and it seems to be working for me.

devforumhelp1.rbxm (10.5 KB)

Found the issue, it is size of the BillboardGui. It is set to (1,0,1,0) and once the bar leaves the middle it stops getting rendered. What you can do is set the size of the BillboardGui to (0,560,0,30) and set the Meter Frame size to (1,0,1,0) and set the position of the same frame to (0,0,0,0)

Or the fixed version here (does the above): devforumhelp1fixed.rbxm (10.5 KB)

1 Like