I’d like to have a billboard properly move along with a model just above it.
When the model is moving, the billboard is indeed moving, just not near the model. That is, it starts with the model but appears to be moving at, say, 1/4 the rate of the model itself. This is not the case for all models… for some models, it is moving properly along at the same rate.
I have checked the settings for billboardgui and reviewed the code, but cannot find anything would cause this.
Here’s a link to a video of the models with the health bar NOT moving along with the model.
Here is the code for the billboard… setting its color, resizing, etc.
-- AngelBall Health Bar
local healthGUI = script.Parent
local thisModel = healthGUI.Parent
--healthGUI.Parent = thisModel.PrimaryPart
function UpdateHealthBar()
local maxHP = thisModel:GetAttribute("HitPointsMax")
local currHP = thisModel:GetAttribute("HitPoints")
local healthchange = 1
if (maxHP ~= nil and maxHP > 0) then
healthchange = currHP/maxHP
if (healthchange < .2) then
healthColor = Color3.fromRGB(255,102,178)
elseif (healthchange < .4) then
healthColor = Color3.fromRGB(255,178,102)
elseif (healthchange < 0.6) then
healthColor = Color3.fromRGB(255,255,0)
else
healthColor = Color3.fromRGB(0,255,0)
end
else
healthColor = Color3.fromRGB(0,255,0)
end
healthGUI.Health.Meter:TweenSize(UDim2.new(healthchange,0,1,0),"In","Linear",0.3)
if (currHP <= 0) then
end
hpPercent = healthchange * 100.0
healthGUI.Health.Meter.BackgroundColor3 = healthColor
healthGUI.HealthLabel.TextColor3 = healthColor
healthGUI.HealthLabel.Text = string.format("%.0f%%", hpPercent)
healthGUI.HealthLabel.TextSize = 8
end
thisModel:GetAttributeChangedSignal("HitPoints"):connect(function()
UpdateHealthBar()
end)
UpdateHealthBar()