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

Health Bar using BillBoardGUI disappears mysteriously?

Asked by 7 years ago

I created a BillBoard GUI that displays a custom health bar above the players head using a tutorial from YT, but for some reason the GUI disappears when my health gets too low. I am extremely confused because it doesn't correlate with anything from the GUI or script. Any ideas?


game.Players.LocalPlayer.Character.Humanoid.Changed:connect(function() local yellowzone = (game.Players.LocalPlayer.Character.Humanoid.MaxHealth / 3) * 2 local redzone = game.Players.LocalPlayer.Character.Humanoid.MaxHealth / 3 if game.Players.LocalPlayer.Character.Humanoid.Health <= redzone then script.Parent.BackgroundColor3 = Color3.fromRGB(255, 0, 0) end if game.Players.LocalPlayer.Character.Humanoid.Health <= yellowzone and game.Players.LocalPlayer.Character.Humanoid.Health > redzone then script.Parent.BackgroundColor3 = Color3.fromRGB(255, 255, 0) end if game.Players.LocalPlayer.Character.Humanoid.Health > yellowzone then script.Parent.BackgroundColor3 = Color3.fromRGB(85, 255, 0) end script.Parent.Size = UDim2.new(game.Players.LocalPlayer.Character.Humanoid.Health / game.Players.LocalPlayer.Character.Humanoid.MaxHealth * 4.75 , 0, .75, 0) print(script.Parent.Size) -- Used to try and debug; BillBoardGUI seems to disappear when the X scale dips below a value of 1.7 - 1.8 (or about 40% of the player's health) end)
0
0 * 4.75 = 0. Use math.clamp to keep it kinda visible. hiimgoodpack 2009 — 7y

Answer this question