So I'm not sure if I'm missing anything here. Im trying to make a skill system that will automatically change levels based on the xp the player has and of course calculate how much xp will be needed to obtain the next level after a level up occurs.
!How it looks in starter player
I have been trying to test this with a gui button that adds 20 xp each time I click it and that works fine. However none of the scripts inside the value object work. I doubt theyre even acknowledged because the first line doesnt display anything in the console.
Here is the GetNextLevelXP code:
print(script.Name .. " exists") local nextLevel = 0 local points, output = 0 local maxLevel = script.Parent.Level.Value print("Running") for i = 1, maxLevel + 1 do points = points + math.floor(i + 300 * math.pow(2,i/7)) output = math.floor(points / 5) nextLevel = output end print(nextLevel) script.Disabled = true
and the LevelUp code:
print(script.Name .. " exists") skill = script.Parent currentXP = skill.Value nextLevelXP = skill.NextLevelXP.Value print("Running") skill.Changed:Connect(function() if (currentXP >= nextLevelXP) then print("LEVEL UP! YOU ARE NOW LEVEL " .. skill.Level .. " IN " .. skill.Name) skill.GetNextLevelXP.Disabled = false end skill.Difference.Value = nextLevelXP - currentXP print("xp gained") end)
PS. To the scriptinghelper or stackedit devs, fix your code markdown! I cant even copy and paste code from the studio without having to edit the whole thing!