How can I make ammo bar go down

I made this GUI and when your gun fires I wanna have the frame go down like -5 studs each shot or depending on how much ammo you have, and when your at 0 the bar refills back to the top.

I don’t know how to do this but I already figured out how to make the bar go back up and just need help with it going down by certain amount per shot

image

in the script:

function Fire()
     --do your gunfired code, make variables for currentammo and totalammo (the ammo in the clip and the clip size)
     currentammo -= 1
     ammogui:TweenSize(UDim2.fromScale(1, 1 * (currentammo / totalammo), "Out", "Quint", 2, true)
end
1 Like

You need to get a value between 0 and 1. This will serve as the percentage of bullets you have left that way you can scale the bar accordingly.

--# Get a value between 0 and 1 that serves as the percent of amount of bullets left
local percentOfBulletsLeft = currentAmountOfBullets / totalAmountOfBullets

--# Now scale the frame by that number
Bar.Size = Udim2.new(1,0,percentOfBulletsLeft,0)
 
1 Like

lol bro, thats exactly what i said

I didnt realize you posted. I was writing my comment as you posted your perhaps ;/

oh ok no worries

303030303030303030303030303030303030

Is there a way to make it go from top down rather than down to top

change the anchor point of the gui to
0, 1

then change the position of the gui to

0, 0, 1, 0

Ok that’s all but the bar goes out of the y size I need is this because how many bullets there are

??????????????????
                   

i have no clue what you mean

This is what happens when I shoot

make the parent of the frame the size you want it to fit in on your screen, then this will make the frame automatically use that size as a reference