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

Leaderboard Script won't Work?

Asked by 10 years ago

I made a leaderboard script. The script shows that if a player has 13500 XP, they would get 1 level. Same with if they got 27000-54000 they would get 1 level. But I'm having trouble with level.Value +1. It keeps saying "= expected near +". I tried doing that but still a red underline. Any help please? Here is the script:

local Use_DB = true 
Cash = script.Parent.Parent.Parent.Parent.Parent.leaderstats.XP
level = script.Parent.Parent.Parent.Parent.Parent.leaderstats.Level

function saveStat(plr,val,key)
    if plr then
        plr:WaitForDataReady()
        plr:SaveNumber(key,val)
    end
end

function loadStat(plr,key,stat)
    if plr then
        plr:WaitForDataReady()
        stat.Value = plr:LoadNumber(key,val)
    end
end

game.Players.PlayerAdded:connect(function(player)
    Stat = Instance.new("IntValue",player)
    Stat.Name = "leaderstats"
    Kills = Instance.new("IntValue",Stat)
    Kills.Name = "Level"
    if Use_DP then
        loadStat(player,"Level",Kills)
    end
    if Cash.Value>= 13500 then
        level.Value +1
        if Cash.Value>= 27000 then
            level.Value +1
            if Cash.Value>= 40500 then
                level.Value +1
                if Cash.Value>= 54000 then
                    level.Value +1
                end
            end
        end

                    end
                end)

Please get me a answer!

2 answers

Log in to vote
3
Answered by
2eggnog 981 Moderation Voter
10 years ago

It should be level.Value = level.Value + 1.

0
Oh, woops. PyccknnXakep 1225 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

When creating a Leaderboard script always add a wait in the PlayerAdded function like so:

repeat wait() until player.Character

The way you changed the values of "Level" is wrong, it should be:

level.Value = level.Value + 1
0
Yeah, i know. I made a mistake. PyccknnXakep 1225 — 10y

Answer this question