Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does my level up script not change my leaderstats, and only change my Gui?

What I'm trying to do is make it so when your xp is over your xp required to level up, you level up. The xp is reset to 0 after leveling up, and the xp required to level up again is also increased, however it is not increasing my level by 1.

wait(3)
xp = script:findFirstAncestor("PlayerGui").Parent.leaderstats.Exp.Value
xpn = script:findFirstAncestor("PlayerGui").Parent.leaderstats.ExpNeeded.Value
level = script:findFirstAncestor("PlayerGui").Parent.leaderstats.Level.Value

while wait()do
script.Parent.Text = xp .. "/" .. xpn 
if xp >= xpn then
	level = level + 1
	xpn = xpn * 1.25
	xp = 0
end
end

-- This makes you level up, and your experience needed to level again is increased. --

1 comment

0

i just edited it into code blocks

1 answer

✓ Accepted answer

Those variables at the top are just storing the values of the Exp, ExpNeeded and Level. If you change the variable, you're not actually changing the value of the objects.

Drop the .Value on the variables at the top so you're referencing the objects themselves, then change the value in the loop using the .Value.

Here's what it would look like

wait(3)
xp = script:findFirstAncestor("PlayerGui").Parent.leaderstats.Exp
xpn = script:findFirstAncestor("PlayerGui").Parent.leaderstats.ExpNeeded
level = script:findFirstAncestor("PlayerGui").Parent.leaderstats.Level

while wait()do
script.Parent.Text = xp.Value .. "/" .. xpn.Value 
if xp.Value >= xpn.Value then
    level.Value = level.Value + 1
    xpn.Value = xpn.Value * 1.25
    xp.Value = 0
end
end

1 comment

0

Thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.