Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a text button take away currency after being clicked?

Asked by 1 year ago
Edited 1 year ago

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?

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

2 answers

Log in to vote
0
Answered by
BD_MI 0
1 year ago

Maybe this gonna help

pathtoyourButton.MouseButton1Click:Connect(function()
    Currency = Currency - 500 -- or your code to subtract it
end)
0
just like that or u can do Currency -= amount mono67890 -2 — 1y
0
Twice works Fouxelefr 7 — 1y
0
this is client sided jedistuff2 89 — 1y
Ad
Log in to vote
0
Answered by 1 year ago

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.

0
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 Cubispaghettis 2 — 1y
0
An example would be: script.Parent.MouseButton1Click:Connect(function() jedistuff2 89 — 1y
0
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 jedistuff2 89 — 1y
0
so do i put " PathWayPoint" instead of button Cubispaghettis 2 — 1y
0
well if the script is in the button, you would do script.parent jedistuff2 89 — 1y

Answer this question