I've made this Exp Bar script to display the Experience of the player out of how much they need to level up. It sets the size originally, when the game begins, but when I change my experience nothing happens.

Code:

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};

function hudsize()
    local Player = game.Players.LocalPlayer
	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 = ((xps[level] * 100)/xp)
		wait(.1)
		local size = (required * 200)
		wait(.1)
		ExpBar.Size = UDim2.new(0,15,0,size)
			
		end

while wait(.5) do
	hudsize()
end

3 comments

0

Why do you need the for loop?

0

Hm, I'll try without it.

0

Edited my question accordingly.