Need a little help.

Hey guys, I feel a little dumb posting this as I feel I should of figured this out already, but I am making a exp bar and it is giving me pains. I have it positioned properly and the formula for length is correct, just one problem. It fills up the wrong way.

Here is a pitcture:

It is cropped so the borders look weird. (sorry c:)

Here is the formula I am using:

surface.DrawRect(354, ScrH()/1.155, 50 ,139.5*(XPCurrent)/(XPNext))

Well, what’s the right way?

At the moment it fills downwards. I need it to fill upwards.

For the y-value in surface.DrawRect, add the height of the entier xp bar (139.5 I’m guessing) and subtract the height of the filled up part (139.5*(XPCurrent)/(XPNext))

Not sure why you would want to use fractional values though.

-- Define the boundaries of the entire XP bar
local BarX = 354
local BarY = ScrH()/1.155
local BarW = 50
local BarH = 139.5

-- Fill in XP
local XPScale = XPCurrent/XPNext
local XPHeight = BarH*XPScale
surface.SetDrawColor(0, 255 , 0, 255)
surface.DrawRect(BarX, BarY+BarH-XPHeight, BarW, XPHeight)

-- Draw borders
surface.SetDrawColor(0, 0 , 0, 255)
surface.DrawOutlinedRect(BarX, BarY, BarW, BarH)

Untested code but should work.

Thanks, I will try this out later as I am not at my PC at the moment.