Need some help with xp bar

my xp broke help

xp = script.Parent.Parent.Parent.Parent.Parent.leaderstats.XP
lvl = script.Parent.Parent.Parent.Parent.Parent.leaderstats.Level
while true do
script.Parent.Text = xp.Value … " / " … 100+lvl.Value * 7
wait(0.1)
end

image its going over the edge and idk why

could you please help, thank you.

2 Likes

The logic for determining the size of the fill bar should be as follows:

X_scale = XP_Value / XP_Goal --//Returns a value from 0-1 or more, might need to clamp it so it's always <= 1

Then you’d set the X scale of the fill bar to that.

In your code you actually didn’t include that part, so I can’t see what’s going on.

whoops i sent the wrong script thats for the number

xp = script.Parent.Parent.Parent.Parent.Parent.leaderstats.XP
lvl = script.Parent.Parent.Parent.Parent.Parent.leaderstats.Level
while true do
wait()
local pie = ( xp.Value / (100+lvl.Value * 5))
script.Parent.Size = UDim2.new( pie , 0 , 0, 20)
end

or just use math.clamp function