Need help with shop/shop scripting

Hello i’ve been working on a simulator type game and I have been designing and scripting the shop gui
but it’s been very hard on me because i’m the only one scripting building gui designing etc. I have a very basic shop script from a very good script @Alvin_Blox
His videos have been very helpful but i’m growing out of things that his tutorials cover so i’m turning to you the roblox dev forum community.

My shop info frame shows the you know info but whenever you buy something the buy button text stay’s Owned/Equip and if you click the buy button multiple times it gives you the item multiple times!
And I do have a gui set up for it.

So I just want it to be a good simple shop where you can equip the item buy it and stuff like a normal would do

If someone can help me script or can even
give me advice for the gui or planning with it. It’s highly appreciated! you can message me on roblox or devforum or @mention me

Thanks :smile:

Besides the basic GUI mechanics, creation, and clicking, you have to keep a few things in mind while creating a shop. The Roblox world of players is full of exploiters that can control everything on the client. The best way is to imagine that they can read and edit your LocalScripts, send RemoteEvents, and disable some of your code.

How does this apply to your shop? Normally (as it should), GUI stuff is handled on the client because everything is nice and instantaneous there. However, since you can’t trust the client and can’t check whether the player has enough money on the client, you must run the checks and give the items on the server. This means communicating between scripts. In English, it should look something like this:

Client: I want to buy Super Incredible Immortal God Sword!
Server: Okay, processing… you only have 2 coppers and want to buy the Super Incredible Immortal God Sword? No way! I’m not giving you the items.

This communication is carried out through Remote Events, a message sent from the client to the server. Looking into those is a must. The server must receive the remote event and check how much money the player has on the server, where exploiters can’t reach. Just something to keep in mind when it comes to transactions involving currency :wink:

1 Like

I’d suggest looking at my reply here : Player not getting tool - #15 by un1ND3X

A “shop system” with explanations as to what is being done, it contains checks too, to guard against multiple purchases or duplicates, utilizes Remote Events*, which are necessary for Client-Server communication.

Basically through buttons, when clicked, a Remote Event is fired, passing the button’s name as the parameter, but the Remote is fired only after some checks have been made, for example if a player clicks the buy button for a tool called “Super Incredible Immortal God Sword!” then on the Client, using that name, the script will check for whether that tool with the exact name exists under the player’s backpack (a player’s inventory),

Each button’s name corresponds to an item stored in Server Storage or somewhere, so that the Server can “pick” that data and store that parameter, a tool’s name for instance, as a variable and subtract the necessary cost from the player’s stats and search for that tool using the name , from where all tools are stored, after that the tool is Cloned to the player’s backpack and then further on, even saved.

If you can do basic scripting and (understand and) work with guis, it would be a good basis for your shop to start with.

Note 1 : Be careful to utilize Remote Events correctly

Note 2 : in my example, a loop is used to set all buttons to fire the event when clicked, no need to manually do it.

I have tried your shop code and yes that is perfect but it’s not what i would need.
Im kinda going for a shop kinda like Ninja Legends. but i will try and merge the code in with a buy button

This is my shop btw. I should of given this for the original post

But thanks for the help. It was very useful

i will help but you have to pay me first

I think… he has already solved the problem. and he wasn’t even looking to recruit.

Attempting to scam are we?

You’re the one who was just asking how to make a Shop Gui here.

Stop breaking the rules.

4 Likes

my friend can help so i offered