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

Why does this resize the wrong way?

Asked by 8 years ago

I am trying to create a healthbar but the form it is in is a wedge so what I did was I have the gradient from red to green so it looks like a good healthbar, and then I have a basic black cover underneath the gradient and another one on top, the one on top, I want to resize over the gradient whenever the player loses / gains health. So lets say theyre at 100 health, and they lose 30, the black cover will cover that 30% lost so it only looks like it has 70% left. Currently it resizes the completely opposite way, and I don't know how I can fix this, it might be something with the math but I am not good at math in general.

The code:

wait(3)

local player = game.Players.LocalPlayer
local character = game.Workspace:FindFirstChild(player.Name)
local humanoid = character:FindFirstChild("Humanoid")


if player and character and humanoid then
    humanoid.Changed:connect(function(newhealth)
        local health = humanoid.Health
        script.Parent:TweenSize(UDim2.new((-health)/100,0,1,0),Enum.EasingDirection.Out,"Quad",0.2,true,nil)
    end)
end

0
Wouldn't it be easier to resize the health bar instead? TheHospitalDev 1134 — 8y
0
No because the gradient would fvck up and still be showing. disassembling 48 — 8y

Answer this question