It’s my first time dealing with an in-game shop/upgrade system. I currently need help to know the best way to do an “owned” system. I’d appreciate it if any of the two examples at the bottom of this post would be a decent method for doing a system like this.
Here is an example of the upgrades frame (not coded yet), where ITEM2 is selected and not already owned. But this has almost nothing to do with the question at all;
The data could possibly look like this for a player:
local Shops = {
ShopOne = {
ITEM1 = true, -- owned.
ITEM2 = false, -- not owned.
ITEM3 = false -- not owned.
}
}
Example 1:
When the player is in the physical-range of ShopOne, the Shop frame opens and the client receives the table/data. The received table/data then sorts the shop with what already is owned or not. Does this have to be done using a Remote Function since it is Client > Server > Client or would it be possible using a Remote Event and how could it be done?
Example 2:
Your own example if you know another or better method…
You could use a RemoteFunction asking the server to retrieve the player’s data table, and then you can use that to update the buttons. (ex: making the text say “Buy for X coins” or “Already Owned”.) Just make sure to use the table as a read-only object; to prevent exploiting. Basically like, just reading the data to determine what to draw on the UI elements, and then when the player attempts to buy something you can then call a RemoteEvent to the server with the item name the player wants to buy. Or, you could utilize a RemoteFunction and have it return a true/false state indicating if the purchase was successful, so you could update the text again with the value returned.
Hope this helps, if you need more clarification or help let me know