Edit: I printed FR and it prints 0.125 everytime the xp is half the required amount.

local user = game.Players.LocalPlayer
local stats = user:findFirstChild("DataFolder")
lvl = stats:findFirstChild("level")
xp = stats:WaitForChild("level"):WaitForChild("xp")
xprequire = stats:WaitForChild("level"):WaitForChild("XpRequire")
local amount = xprequire

print(xprequire.Value)
wait(1)

local function changed() -- This is the bar btw
    local FR = (xp.Value / (lvl.Value * amount.Value))
    script.Parent.Size = UDim2.new(FR, 0, 0, 50)
end

xp.Changed:connect(changed)
xprequire.Changed:connect(changed)
lvl.Changed:connect(changed)

while true do
	wait()
	script.Parent.Parent.Text = xp.Value.. "/ " ..amount.Value
	script.Parent.Parent.Parent.LevelShow.Text = "Level " ..lvl.Value
	
	if xp.Value >= amount.Value then
		lvl.Value = lvl.Value + 1
		wait()
		xp.Value = 0
		amount.Value = amount.Value * 2
	end
	if amount.Value == 0 then
		amount.Value = 100
	end
end

while true do
	wait()
	script.Parent.Parent.Parent.LevelShow.Text = "Level " ..lvl.Value
end

6 comments

0

Add a print after line 12 'print(FR)' and make sure the variable FR is the actual size you want the XP bar to become.

0

I printed FR and it prints 0.125 everytime the xp is half the required amount

0

and the size of the outer bar is {0, 235},{0, 50}

0

And where the bar "function" is it uses events rather than a loop for this type of thing.

0

You should never use a loop to check if a property changes. Bad practice.

0

Its fine now i got it all figured out i just rewrote it but more simple