Why does this resize the wrong way?
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:
03 | local player = game.Players.LocalPlayer |
04 | local character = game.Workspace:FindFirstChild(player.Name) |
05 | local humanoid = character:FindFirstChild( "Humanoid" ) |
08 | if player and character and humanoid then |
09 | humanoid.Changed:connect( function (newhealth) |
10 | local health = humanoid.Health |
11 | script.Parent:TweenSize(UDim 2. new((-health)/ 100 , 0 , 1 , 0 ),Enum.EasingDirection.Out, "Quad" , 0.2 , true , nil ) |