Best method of storing UUIDs?

Hi! I’m trying to use UUIDs generated using HTTP Service to mitigate the risk of item duping and exploiting in a game I’m working on. I understand the generation part, but what would be the best way of storing these IDs in data stores? I need a way to link the item name and the ID in a data store.

1 Like

You could try an approach such as tagging/storing each item with a UUID. In this example both items have the exact same properties but a different UUID, so are still distinguishable from one another.

local Items = {
	{
		Name = "Quint",
		ObjectType = "Teddy Bear",
		UUID = "4FEF8955-33AC-4146-8FE8-F530D7C496A0",
		Color = Color3.fromRGB(170, 85, 0)
	},
	{
		Name = "Quint",
		ObjectType = "Teddy Bear",
		UUID = "71B741FF-12BD-41D6-BAB4-87309E8DAE51",
		Color = Color3.fromRGB(170, 85, 0)
	}
}

Or instead, having each key for each object be a UUID.

local Items = {
	["4FEF8955-33AC-4146-8FE8-F530D7C496A0"] = {
		Name = "Quint",
		ObjectType = "Teddy Bear",
		Color = Color3.fromRGB(170, 85, 0)
	},
	
	["71B741FF-12BD-41D6-BAB4-87309E8DAE51"] = {
		Name = "Quint",
		ObjectType = "Teddy Bear",
		Color = Color3.fromRGB(170, 85, 0)
	}
}
1 Like

Rlly late on this one but storing UUIDs as strings to the DataStore is rlly inefficient. One Character is almost a BYTE! So with just the UUID you are storing 360 BYTES of data. UUIDs for most applications are really an overkill, you can stick to just using integrers which take up just 32 bits which is 4 bytes. If you are planning to use this for inventory I really recommend just using integers for item identification :smiley:
As per you question I would just use a different scope, and let the ID be the key. Under that you can store the json encoded table of the rest of the ifnormation.

Regarding the integer approach, of course UUIDs are much better at the job they were meant to do - identifying, but data size should also be taken into cosnideration.

1 Like

Integers would not work for this because he’s tracking unique items. A UUID (universal unique identifier) is used to uniquely identify objects and guarantees each value to be different (at least extremely likely to be different) from other values being generated. Integers lack this property and run into duplicate errors.

Also this is 2024, we don’t need to ration bytes anymore. Using a UUID is fine

Actually with the integers (recnetly changed to doubles instead of int64) 2^53 you have a plenty of room, so chance of 2 items having the same ID would be unbelivably low, 2/2^54 (lower bound and upper bound thats why the extra x2), DOn;t get me wrong but that’s good enough, I would like to point out it takes way less space. However as I have mentioned before both have their aplications and use cases. Keep in mind with roblox storage limits being around 4mb that leaves u with being able to store only 8700 UUIDs!. 8700UUIDs per scope aka player only. Nevertheless still pointing out that both have usecases.