I've been interested in learn scripting. So, i was testing some learderstats scripts when this happened:
Script
local Detector = script.Parent:WaitForChild("ClickDetector")
Detector.MouseClick:Connect(function(player)
local player = player.Name
game.Players.player.leaderstats.Cash.Value = 30
end)
Output
"player is not a valid member of Players"
Can someone explain what's wrong with the script please?

3 comments
MouseClickalready returns the player; you're getting the player's name from the player itself on line 4, then attempting to get the player from the player's service when you already got the player? https://developer.roblox.com/api-reference/event/ClickDetector/MouseClickshtu up @theedethAcaster. Ok so this is ur problem, u should be doing for line 5, this: game.Players[player].leaderstats.Cash.Value = 30
yeah