In my game players are gonna be able to trade different items between eachother. In the past I have seen many games struggle with duping and other sort of exploits that allow items to be duplicated.
All items in my game are assigned a UUID once they are added to a player so that they can be distinguished. But from my understanding most dupes rely on rejoining a game before the trade going through actually saves, therefore the player still keeps the item since the data didn’t update.
I was thinking of making a separate datastore key storing all of the UUIDS and just referencing a “Owner” as a playerID so it could always verify that one item doesn’t have two owners. But this got me a bit worried about the datastore 4mb limit, seems to me that limit would be reached quite fast if thousands of players have hundreds of items on them.
So, I would like some tips on how I could implement a system to prevent this and if it’s even necessary.
You’d need to add many checks to ensure that the trade goes through. If a player leaves before the trade finishes, detect this and revert the trade/complete it.
People will always find ways to dupe, so just patch them as you go and ban those who exploited these bugs.
The UUID assignment is a good idea, but maybe only give UUIDs to items with larger value
Adding onto @incognitobot_rblx’s answer, Implement a “suspend” state for items involved in a trade. If a player disconnects, their trade should be canceled, and the items involved should be returned to the original owner. Also when starting the trade, you can “lock” the players inventory, so no actions (like additional trades, item usage, or leaving the game) can happen during the trade
But for the most part, it’s just making it to the best of your abilities, then patching them later on, there’s no such thing as perfect code, exploiters will always find ways to get around it
edit 2: i believe a datastore wouldn’t be the best idea, as with a lot of players / items it can be an expensive operation, which would further yield the game, giving the exploiters more opportunity to find security flaws