XP bar isn't changing in size

I have an XP bar that works for the most part other than the fact that it doesn’t actually change in size but it does update the amount of XP you have/need.
image

It stays at the same size no matter how much XP you gain. I was wondering if anyone could help me come up with a solution to this or point out what the problem is. Thanks.

The goal I had in mind for it was to grow gradually and once you get the amount of XP you need it will reach the end and then reset back to its original state and do it all over again.

Code:

local player = game.Players.LocalPlayer

local leaderstats = player:WaitForChild("leaderstats")
local datafolder = player:WaitForChild("Data")

local playercurrentxp = leaderstats.XP
local xpNeeded = datafolder.xpNeeded

local pie = ( playercurrentxp.Value / (xpNeeded.Value + 10))


function updateXPBAR ()
	script.Parent.Size = UDim2.new( pie ,0, 0, 10)
	script.Parent.Parent.Parent.TotalXP.Text = playercurrentxp.Value.."/"..xpNeeded.Value
	
end

updateXPBAR()

playercurrentxp:GetPropertyChangedSignal("Value"):Connect(function()
	updateXPBAR()
end)

You have to move this line inside the function.

1 Like

Wow :man_facepalming: didn’t know it was that simple lol. Thanks for the help man.

1 Like