Hello I am trying to make GUI that becomes more and more transparent as your Health goes lower does anybody have any idea like how it should be?
local humanoid = game:GetService("Players").LocalPlayer.Character:WaitForChild("Humanoid") local gui = script.Parent humanoid.HealthChanged:Connect(function() local percent = humanoid.Health/humanoid.MaxHealth gui.BackgroundTransparency = percent end)
Keep in mind this script makes the transperancy goes higher as the health goes higher and when you're at 100% Health, it's just full transparent when I want it to be 0% Transparent when it's 100%
Change line 7 to this:
gui.BackgroundTransparency = 1 - percent
The "percent" variable starts as 1 as the health is in max. When the player gets 25 damage points (assuming the max health is 100), then the "percent" variable becomes 0.75. Subtracting 0.75 to one gets us 0.25, increasing the transparency.
(edit 1: quick fix about my math)