How would I make a global shop?

I’m trying to make a game similar to “Trade Simulator” and I’ve made a shop, but I’m stuck on how I could publish items to the shop so it can be resold. How could I create an item and make it display globally on every server with the parameters in the image provided?

I read a devforum post about it saying to use MessagingService, but it doesn’t make sense to me.
Screenshot 2023-10-06 214658

2 Likes

you could use arrays (dictionaries) to pass over and then use for loops to open it out
for example:

local Item = {
    [`Name`] = `data`;
    [`Price`] = 100;
    [`AssetId`] = 12345; -- // you may also want to convert this to rbxid://bla bla idk how to do it without looking
    [`Stock`] = 10;
    [`isCustom`] = true; -- // or false
    [`isLimited`] = true;
}

-- // This should print the elements name first then the elements data
for Element,ElementData in pairs(Item) do
    print(`ElementName: {Element} ElementValue: {ElementData}`)
end

3 Likes

sorry I’m confused right now… how would I use that to make the item display on the shop globally?

1 Like

you can use oop or for loops to go through the table and add elements
image

local element = ui.Frame.Element -- // have like a template seek image above for what i mean
-- // do the for loop here
local ui = element:Clone()
-- // change the ui elements or use oop to make new ui
1 Like

I forgot to mention that I already made a script that creates the item and displays it, I just want it to display globally on every server. Sorry if I’m confusing :sweat_smile:
Screenshot 2023-10-07 105640

1 Like

fireallclients with the update and change the ui with that, you could probably pass along the element in a remote event

1 Like

As @ar_qx mentioned, you should represent the data of the said item as a dictionary. With that in mind, you need to create the following:

  1. A method for converting the textbox inputs to the dictionary, make sure to check the input is valid, sanitize, make type conversions where needed, etc.
  2. A method for sending the dictionary to the server, for this you can use remote events. Make sure you check if the player argument userId is your userId on the server, else exploiters will be able to upload items to the shop.
  3. A method for sending the item data to active servers, for this you can use something like MessagingService to send the dictionary to other currently running servers.
  4. A method for sending the item data to servers that aren’t created yet, for this, you can use a Roblox datastore to store all the current items. Add the new item to the datastore and make every server fetch the items once at startup(no need to fetch multiple times due to messaging service).
  5. A method for fetching the dictionary from the datastore and messaging service and sending it to the clients(and also the clients who connect after fetching the items).
  6. A method for converting the dictionary to a GUI item in the client shop.
2 Likes

This helps very much. Thanks a lot!

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