Hello, so basically I made a text button, and I want that text button to take away 500 Points of your leaderstats currency when clicked. Anyone know how?
Maybe this gonna help
pathtoyourButton.MouseButton1Click:Connect(function() Currency = Currency - 500 -- or your code to subtract it end)
To remove currency when a button is pressed, You have to create a localscript, a remote event and a script In the localscript, write:
Button.MouseButton1Click:Connect(function() --replace Button with the path to your button game.ReplicatedStorage.RemoteEvent:FireServer(500) -- replace RemoteEvent with the name -- of your remove event end)
in the script write:
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, amount) player.leaderstats['Currency Name Here'] -= amount end)
If you were to remove the current on the client side, the currency would only get removed for the player. The other players and the server would not detect a change in the currency.