Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how to resize a gui backwards?

I am making a healthbar. In normal bar guis, sizing it down makes it decrease towards the left, I want it to decrease towards the right, making the gui backwards. Yes i could make an overlay and just increase it normally to the right making the layer under it look like its decreasing towards the right, but i dont want to do that. How can i resize a frame backwards? thank you

1 answer

✓ Accepted answer

It's quite simple, if i got you right, you just need to tween/set position of the health bar too.

Let's say you have 50% health and your health bar size is 0.5 on scale, you would set it's position to 0.5 on scale too, if i am sure this should be fix for that. The only problem i see with that is if health is for example 20%, you would set health bar size to 0.2 but you would have to move it by 0.8, not by 0.2 so all you have to do is get like default bar size value like this

local MaxSize = 1 -- assume it's one

local HealthPercent = 20

Bar.Size = UDim2.fromScale(MaxSize / HealthPercent, 1)
Bar.Position = UDim2.fromScale(MaxSize - (MaxSize / HealthPercent), 0)

I don't know how you position your bar so it might be different than in your situation but if you want to fix this example, you would make a frame which would have size of the bar and the put new frame inside the frame which would be the actual bar, that way you have max size 1 and min is 0 making it extremely easy to manage.

1 comment

0

Hey thanks it works, of course the percentage thing was wrong because it would make it too small if divided by 20 so i changed that to healthpercentage / 100, and it works! Thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.