I’m working on a game that requires a tool trading system, but i dont know how i should start. I’d like a simple GUI that shows icons of tools that have been put into trade.
I have sort of the idea i’m going for, i just dont know how I would be able to start scripting it.
Determine if User B accepts the previous user’s trade.
If trade was accepted, throw both players into a new active trade, and by using RemoteEvents, display the trade window for both players in the trade.
When ever either player adds a new item to their trade, fire a remote to the server for the server to replicate what item they added to the player that they’re trading with, so they can see what they would get. (so basically store the players who are trading in a table, then have the server attempt to locate them so you know who to fire the remote to)
When either user selects the Accept Trade button, do the same step as above but this time replicate their Accept Trade button so the user knows they’re going to accept the trade. However, if an item in the trade request was modified in the previous step, make the Accept Trade button red for both users as when ever one user modifies the trade they should need to accept it again, so they know what they’re getting.
When ever a user selects the Accept Trade button, fire a remote to the server, and determine if both players have accepted the trade. If so, process the trade. If either player exits out of the trade, a remote should be fired to the opposing player to hide their trade GUI, and then clean up the cached data for that trade in any tables.
Another important thing to note here is security. Verifying players have the items they’re attempting to trade using server-sided checks, and switching flags (boolean variables) to true/false for each player if they’re eligible to accept the trade. Like I mentioned earlier, if a new item gets modified in the trade by either player, both of the player’s AcceptTrade flags should be again set to false, so no player can try to pull a fast one to scam them.
I got wordy on this one. I can help clarify anything that sounds redundant or doesn’t make sense.
Hopefully this gives you a better outline as to how the structure would look for this type of system.