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

help me with this error Workspace.Map1.Coins.Part.Script:4: attempt to index nil with 'leaderstats'?

Asked by 3 years ago

i got this error when i collect the coins around my map

17:05:11.658 - Workspace.Map1.Coins.Part.Script:4: attempt to index nil with 'leaderstats' 17:05:11.659 - Stack Begin 17:05:11.659 - Script 'Workspace.Map1.Coins.Part.Script', Line 4 17:05:11.660 - Stack End

script.Parent.Touched:Connect(function(hit)
    local player = hit.Parent:FindFirstChild("Humanoid")
    local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
    if plr.leaderstats.Cash.Value >= 0 then
        wait()
        script.Disabled = true
        script.Parent.Transparency = 1
        script.Parent.CanCollide = false
        plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + 1
        wait(5)
        script.Parent.Transparency = 0
        script.Parent.CanCollide = true
        script.Disabled = false
    end
end)

i frequently get this error everytime i collect the coins but it doesnt affect my game. I would appreciate your solution for this. Thankyou!

0
Where is your leaderstats script? Did You Instance it/ JeffTheEpicRobloxian 258 — 3y
0
yeah i instance it Blackbooks 138 — 3y

Answer this question