Log in to vote

how to resize a gui backwards?

Asked by 11 days ago

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

Log in to vote
Answered by
imKirda 2248 Moderation Voter Community Moderator
11 days ago
Edited 11 days ago

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.


Answer this question