How to make a shop

Hi everyone. Basically I’ve made this topic because I was wondering how I’d make a button that, when you click it, it checks to see if a leaderboard stat is enough, like let’s say a gun is 50 coins, and then if you do have enough coins, it takes away the respective value of the leader stat and gives you a badge.
The button is a gui.
So when you click it, it checks the stats value, if it’s 50 or over, it takes away 50 from the value and also grants you a badge.
Please help. I don’t understand badge making very much, or deducting currency.

if currency.Value >= price then
currency.Value -= price --takes away the amount of the price from the currency
end

you can also search up a tutorial on yt for the badges :pray:

1 Like

oh nvm i found something abt badges

here

BadgeService
Remotes
Logic

Player clicks GUI button, local script does its own sanity check to see if it would pass & if passes: fires a remote that the server will be listening for, server does the sanity check again & if passes: reduces the players leaderstat and uses BadgeService to award badge.

The client should also do a pre-check to see if they already have the badge as they join, if they do: make button do something else / remove it.

You run the sanity check on the client, even though unnecessary, to save the server from maybe spending more resources than it needs to. Offloading this initial work is nice for the server, even if it will just repeat it.

IF not using GUI, you could ignore remotes and have the server handle it itself. Probably using a ClickDetector or a ProximityPrompt or something functionally similar. If you modify the physical button though be aware it would change for everyone due to server replication. If you want the button to only change for some players, use a remote to fire the specific player some data.

2 Likes

You were a big help. Thank you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.