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?
How to make a text button take away currency after being clicked?
2 answers
Maybe this gonna help
pathtoyourButton.MouseButton1Click:Connect(function()
Currency = Currency - 500 -- or your code to subtract it
end)
3 comments
just like that or u can do Currency -= amount
Twice works
this is client sided
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.
5 comments
I kinda understand but what does it mean by "replace remote event by name of my remove event" like what type of thing am i supposed to put there and for the Path to my button, do i put where it is? Can u show an example
An example would be: script.Parent.MouseButton1Click:Connect(function()
And for the remoteevent thing, create a remote event in replicatedstorage and name it whatever, then in the script and in the localscript, replace the RemoteEvent text with the name of your remote event
so do i put " PathWayPoint" instead of button
well if the script is in the button, you would do script.parent
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
My answer to your previous question about paying to teleport is the same concept; all you need to do is remove the teleport bit.