I have recently been making a game where I need to make the leaderstats to grow by 1 when a player clicks on a particular part. I have tried hard to make it work but I can't solve the problem. Can you help me? I will remember to accept a fulfilling answer
game.Players.PlayerAdded:connect(function(player)
local StartingMoney = 0
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local money = Instance.new("NumberValue")
money.Name = "Money"
money.Parent = leaderstats
money.Value = StartingMoney
game.Workspace.Part.ClickDetector.MouseClick:Connect(function()
local pstats = game.Players[player.Name].leaderstats
pstats.Value = money + 1
end)
end)
