What is the best way to store Item identificators?

The problem with this solution is the fact I would need to store another data to keep track of how many items the certain user created because you can just delete the item and this will cause duplicated ids.

That is true. Honestly I can’t really provide anymore help and at this point, it is up to you to experiment with data to see what fits your needs. Hopefully what I and others have provided is enough for you to come to your solution. Good luck.

1 Like

I don’t want to end the discussion without the solution code so here’s what I came with:

It is using real time so every hour there is space for another 9^35 random characters in the ID. The actual reason why I didn’t use Player UserId is because I don’t know how big is roblox going to be in the future and UserIds are probably going to be much bigger number than they’re right now and if you want to store those IDs you are going to hit the 4MB datastore limit sooner than you think.

This ID can have maximum of 20 characters as of right now.

local function GenerateID()
    local GUID = Http:GenerateGUID(false)
    local t = os.date("*t")
    local SubID = GUID:gsub("-",""):sub(1,9)
    local TimeID = string.format("%s%s%s",t.hour,t.yday,t.year)
    
    --// returning the new ID
    local ID = string.format("%s%s",TimeID,SubID)
    
    return ID
end

So if I am right probability of getting duplicated ID is almost impossible.

3 Likes