hey there so I'm making a game and a sell area for points ok? so when i touch the brick my script is:
script.Parent.Touched:Connect(function() if game.Players.LocalPlayer.leaderstats.Potatoes.Value == 6 then game.Players.LocalPlayer.leaderstats.Cash.Value = game.Players.LocalPlayer.leaderstats.Cash.Value +10 end end)
and it get this error:Attempt to index nil with leaderstats

1 comment
local currencyName = "Cash" game.Players.PlayerAdded:Connect(function(player) local folder = Instance.new("Folder") folder.Name = ("leaderstats") folder.Parent = player local currency = Instance.new("IntValue") currency.Name = currencyName currency.Parent = folder local currency = Instance.new("IntValue") currency.Name = ("Potatoes") currency.Parent = folder end)