Hello there. I'm making a shop system and when I do a if stament to see if the player has enough money to buy the item it gives me this error.
workspace.Apple.Script:2: attempt to index nil with "leaderstats"
Here's the code I'm using
script.Parent.ClickDetector.MouseClick:Connect(function()
if game.Players.LocalPlayer.leaderstats.Money.Value >= 3 then -- heres the part im talking about
game.Players.LocalPlayer.leaderstats.Money.Value = game.Players.LocalPlayer.leaderstats.Money.Value - 3 -- dont worry its just the text doing that
end
end)
also this for somereason
game.Players.LocalPlayer.leaderstats.Money.Value = game.Players.LocalPlayer.leaderstats.Money.Value - 3 -- sorry, the text did that

2 comments
Are you running the code in a LocalScript or a Script?
a script