script.Parent.MouseButton1Down:Connect(function(hit) local player = game.Players:FindFirstChild(hit.parent.Name) player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 10 script.Parent.Visible = false
i want to make button that spawn part for 100$ but for test i coded button gives u 10$ but didnt work
Next time use a lua button, and remote events.
-- Errors:--
player:WaitForChild("leaderstats")
This player.leaderstats.Cash.Value + 10
will not replicate to the server. You need that for the stats to change for every client (user)
-- Tips
Use game.Players.LocalPlayer
instead of that game.Players:FindFirstChild(hit.parent.Name)
-- Extra: --
Use the code example 1 below with a local script!
-- Code example 1, button script: --
script.Parent.MouseButton1Click:Connect(function() local player = game.Players.LocalPlayer game.Re end)
-- Code example 2, remote event script: --
script.Parent.OnServerEvent:Connect(function(player) player.leaderstats.Cash.Value += 10 end)