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

How do I fix this "attempt to index nil with 'userId`?

Asked by 3 years ago
local function LoadLeaderboardSave(player)
        if player.userId <= 0 then return end --error here
        player:WaitForChild("leaderstats")
        wait()
        local leaderboardStats = leaderboardData:GetAsync(player.userId)
        for i, stat in pairs(leaderboardStats) do
            local currentStat = player.leaderstats:FindFirstChild(stat[1])
            if not currentStat then return end
            currentStat.Value = stat[2]
        end
        Print("Loaded "..player.Name.."'s leaderstat data")
    end

this is the error ServerScriptService.Leaderboard:167: attempt to index nil with 'userId'

0
provide us with more information about the script, the error at line 167 Blackbooks 138 — 3y
0
show the part where you use LoadLeaderboardSave() i think the player param is wrong BulletproofVast 1033 — 3y

Answer this question