Inside the player I have a IntValue called CraftingLevel and inside that a IntValue called CraftingEXP, inside that is this script (normal script), I wanted to be able to level them up like so, but it refuses to work:
EXP=script.Parent Crafting=script.Parent.Parent EXP.Changed:connect(function() if EXP.Value*10 == Crafting.Value and Crafting.Value<10 then EXP.Value = 0 Crafting.Value = Crafting.Value+1 end end)
Thanks
Try
if EXP.Value >= Crafting.Value * 10 then
instead.
If you don't want linear leveling (every level has the same number of steps between), try this:
if EXP.Value >= Crafting.Value ^ 3 then
And here's a more efficient code (in case they gained a bunch of EXP where they gain more than one level:
local EXP = script.Parent local Crafting = script.Parent.Parent EXP.Changed:connect(function() while EXP.Value >= Crafting.Value * 10 do EXP.Value = EXP.Value - Crafting.Value * 10 -- Make sure this part is exactly the same as what is checked for in the conditional statement. Crafting.Value = math.min(Crafting.Value + 1, 10) -- Limits the level value to a maximum of 10 end end)