Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My level system does not work, instead of leveling up it keeps going, what is wrong with script?

Asked by 3 years ago

like, everything works, when I walk exp goes up as expected but when exp hits max it does not level up, it just keeps going, here is my script in serverscriptservice, I apologize for bad english

local maxXp = 20
game.Players.PlayerAdded:Connect(function(player)
    local levelinfo = Instance.new("Folder")
    levelinfo.Name = "LevelsInfo"
    levelinfo.Parent = player

    local level = Instance.new("IntValue")
    level.Name = "Level"
    level.Value = 1
    level.Parent = levelinfo

    local exp = Instance.new("IntValue")
    exp.Name = "Experience"
    exp.Value = 0
    exp.Parent = levelinfo


    local xpNeeded = Instance.new("IntValue")
    xpNeeded.Name = "expNeeded"
    xpNeeded.Value = 20
    xpNeeded.Parent = levelinfo


    exp.Changed:Connect(function(newExp)
        if exp.Value >= xpNeeded.Value then
            level.Value += 1
            exp.Value -= xpNeeded.Value
            xpNeeded.Value = xpNeeded.Value + 2
        end
    end)

end)

this part here does not seem to do anything

    exp.Changed:Connect(function(newExp)
        if exp.Value >= xpNeeded.Value then
            level.Value += 1
            exp.Value -= xpNeeded.Value
            xpNeeded.Value = xpNeeded.Value + 2
        end
    end)
0
Are you sure that you are Changing the Values for the exp from the Server. MineBlox_Artz 65 — 3y
0
Yes, it shows on gui too and when I test it and check it exp value goes up. Sabailuridze 126 — 3y
0
does the exp.Changed function fire? MineBlox_Artz 65 — 3y
0
idk what happened but I copied everything in that script then deleted whole script, then created new script at same place and copied all stuff in it, now it works Sabailuridze 126 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

I tried recreating the problem, but there seems to be no Problem. I have sent my .rblx file as an example to how it may work

Test_Works.rbxl

Ad

Answer this question