I have an Experience Bar script that I wrote, and it's really been bugging me. For some reason, it sets the bar to size 200 for practically every experience value OTHER than 0. If I set it to 0, the Size is correct, but if I set it to, for example, 50, the size is 200. What is wrong with it?
wait(2)
local xps = {0, 3, 6, 10, 15, 20, 25, 30, 40, 50,
65, 80, 95, 110, 125, 140, 155, 180, 210,
250, 300, 350, 400, 450, 500, 575, 650, 725,
825, 1000};
Player = game.Players.LocalPlayer
function hudsize()
repeat wait() until Player and Player.leaderstats
local ExpBar = script.Parent.ExpBar
local xp = Player.Exp.Value
local level = Player.leaderstats.Level.Value
local required = math.ceil(xp/(xps[level+1] * 100))
if level < 30 then
wait(.2)
ExpBar.Size = UDim2.new(0, 15, 0, (required * 200))
elseif level >= 30 then
wait(.2)
ExpBar.Size = UDim2.new(0, 15, 0, 200)
end
end
Player.Exp.Changed:connect(function()
hudsize()
end)

2 comments
I used what you gave me, and it gave me an error "Cannot perform arithmetic on userdata value" or something like that, so I changed line 16 to say (xp.Value/(xps[level.Value+1]) * 100) and it just gave me the same problem.
You have to move that to required aswell, Let me update it. -- It's updated