Anti item dupe system

Hello, I’ve been wondering how I’d make an anti item dupe system that works with ids
I thought I’d assign into the player data an id and in another datastore the id would have the player user id & item name, etc but I think it’s gonna get rate limited very fast if I check for every items.

thanks

1 Like

You don’t need to use Datastores, just check the items in the game. I use something like this for a game I’m working on; every item is assigned an Id and once it’s added to someone’s backpack is checks every item in the game to see if an item with the same id already exists, if it does just delete it. If you are saving items to a datastore, just wait until this process has finished with a flag of some sort somewhere and then continue with your saving.

The item does not need to have the same Id every time you join the game because you’ve already verified it’s one of it’s kind so you can just save the item name and make new ids in runtime :slight_smile:

2 Likes

Treat the Cause, Not the Symptom

Stop duping instead of trying to delete duped items.

If you just bandaid the issues with your code it will become slow and hard to work with.

3 Likes

I don’t understand a lot, is that do what you mean ? :thinking:

local Cache = {}
local CacheTimeout = 60 

function canUseItem(player, itemID)
	if Cache[itemID] then
		local cacheEntry = Cache[itemID]
		if cacheEntry.timestamp + CacheTimeout > os.time() then
			if cacheEntry.playerID == player.UserId then
				return true
			else
				return false, "You do not have permission to use this item."
			end
		else
			Cache[itemID] = nil
		end
	end

	local success, result = pcall(function()
		return game:GetService("DataStoreService"):GetDataStore("items"):GetAsync(itemID)
	end)

	if success then
		if result.playerID == player.UserId then
			Cache[itemID] = {
				playerID = player.UserId,
				timestamp = os.time()
			}
			return true
		else
			return false, "You do not have permission to use this item."
		end
	else
		return false, "An error occurred while checking the item."
	end
end
1 Like

This! I agree, but having a “cure” for both definitely will help because exploiters are slippery. Make sure your item handler’s infrastructure is good and everything that uses it won’t cause any duping with faulty logic; but having a layer of protection if anything does slip through definitely helps, and if something does slip through, you can log it and investigate the cause.

2 Likes

do you mean it only checks in the same server?

1 Like

The simple answer is do not let the client send information to the server about what items they have. As a general security rule, only allow the player to request that their items be changed. The server should verify that their request is legitimate. An easier implementation would be to do what you mentioned with item ID’s, but you don’t need any datastore for that. You’d just have to make sure that the player doesn’t possess two items with the same ID.

2 Likes

Yeah. That’s all it needs to do, because we wouldn’t save 2 of the same items if we checked it in the same server anyways.

1 Like

ok but like what if they do a basic crash dupe thing & they both go in different servers?

i never said that i do that, im just asking how i’d make an anti dupe system

Explain to me how a crash dupe works.

The script i sent is what you searshed ?

person A has an item he gives it to person B
person B leaves the server (their data is saved & has the item)
person A crashes the server they’re in making their data not save (their data isnt saved & they still have the item)

You can check the players inventory every so on and check if the player has more than 1 of the same item, or if you have a RemoteEvent to give the player items, check if the player is firing it excessively.

not what i asked, i dont use those types of system im just asking how i’d make an anti dupe system using items uuids

It kinda seems like an issue with crashing the server if I’m being honest. But game:BindToClose doesn’t catch this?

Like said before, you do not need DataStores. Checking items in the game is enough, but you do you.

no it doesnt because the server is crashed & not closed normally

maybe you should read the full post/thread to find out which type of dupe i’m trying to avoid