Hello!, i would just want to explain taht i am very new to scripting so sorry for any dumb mistakes. I am trying to give a player "coins" when they touch a chest and i have a coins value inside of a folder called leaderstats located in all players. When i try to give the player coins it gives me the error: 12:30:57.073 - Workspace.CHESTS.Part.Script:3: attempt to index nil with 'WaitForChild'
the script:
script.Parent.Touched:Connect(function()
local player = game.Players.LocalPlayer
player:WaitForChild("leaderstats").Coins.Value = player:WaitForChild("leaderstats").Coins.Value + 50
end)``
images: https://gyazo.com/63f44864750049f3dfd76aa2cabbd595
When playing the leaderstats looks like this https://gyazo.com/31ed8c7be918a2a2f6adacbed58ed63e

2 comments
What the hell is game.Playersplayer[player]?
Sorry, it's game.Players[player]