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

attempt to index nil with 'leaderstats'?

Asked by 1 year ago
Edited 1 year ago

**I have tried to find what the error is but im new to studio and dont understand can someone please help me! **

script.Parent.Touched:Connect(function(hit)

    if hit then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if player.leaderstats.Coin.Value >= script.Parent.Requirement.Value then
            player.leaderstats.Coin.Value -= script.Parent.Requirement.Value

            for i,v in pairs(workspace.Maps.DesertMap:GetChildren()) do
                v.Transparency = 1
                v.CanCollide = false
            end
        end
    end
end)

0
I am trying to make a door that when you walk into it your money will be deducted from ur coins Coolmansunsh 26 — 1y
0
What does attempt to index nil with mean Coolmansunsh 26 — 1y

1 answer

Log in to vote
0
Answered by
boredlake 256 Moderation Voter
1 year ago

I think the issue is you have to create a leaderstats folder before trying to call it. It does not automatically get inserted into the player, so you have to make it yourself. Try searching for how to make a leaderboard if you don't know how.

0
Thanks Coolmansunsh 26 — 1y
Ad

Answer this question