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

why won't my leaderborad work?

Asked by 10 years ago

I feel like there is something wrong. Can anyone help me? The Leaderboard won't show

scoreKey = "PlayerScore"
levelKey = "PlayerLevel"

function onPlayerEntered(newPlayer)
    if newPlayer.Name ~= "Player1" then
    newPlayer:WaitForDataReady()
    end

    local stats = Instance.new("IntValue")
    stats.Name = "leaderstats"

    local kills = Instance.new("IntValue")
    kills.Name = "Knockouts"

    local points = Instance.new("IntValue")
    points.Name = "Points"

    kills.Parent = stats
    points.Parent = stats
    stats.Parent = newPlayer    

    kills.Changed:connect(function() onXPChanged(newPlayer, kills, points) end)
    points.Changed:connect(function() onlevelChanged(newPlayer, kills, points) end) 
    newPlayer.Changed:connect(function (property) end)

local ok, ret = pcall(function() return newPlayer:LoadNumber(scoreKey) end)
    if ok then
        if ret ~= 0 then
            kills.Value = ret
        else
            print("Nothing to load/score was 0")
        end
    else
        print("Error:", ret)
    end

    local ok2, ret1 = pcall(function() return newPlayer:LoadNumber(levelKey) end)
    if ok2 then
        if ret1 ~= 0 then
            points.Value = ret1
        else
            print("Nothing to load/score was 0")
            end
    else
        print("Error:", ret1)
    end

Answer this question