GUI Bar fill up thing not working?

So basically the game has 2 values, fart meter and fart goal. Fart goal is a number that doesn’t change; it’s the limit your fart meter can go before you poop your pants. The fart meter is how many times you’ve farted. It fills up the bar as it goes up. Or at least that’s what it should do, but instead it does something like this…
robloxapp-20220407-2037482.wmv (661.7 KB)
Here is my code:

local player = game.Players.LocalPlayer
local fartmeter = player.FartFolder.FartMeter
local fartgoal = player.FartFolder.FartGoal
fartmeter:GetPropertyChangedSignal("Value"):Connect(function()
	script.Parent.FilledBar.Size = script.Parent.FilledBar.Size + UDim2.new(0, script.Parent.Size.X.Offset / fartgoal.Value, 0, 0)
end)

Please let me know if there is a way to fix this. Help would be appreciated.

1 Like

First of all, I think that your UI should be in scale, not offset, because scale basically changes the size of the UI proportional to the screen size. So that means that it will scale down properly in Mobile, and scale up properly on console.

Also, instead of adding to the size, I would just resize entirely to make sure that it doesn’t accidentally go over the limit.

-- you would do this instead
local NewSize = fartmeter.Value / fartgoal.Value
script.Parent.FilledBar.Size = UDim2.new(NewSize, 0, 1, 0)

I wrote this on my phone, so let me know if it helps!

It did help, sorry for my slightly late reply. Thanks

2 Likes