How to generate UID?

if you want it to perm prevent from getting the same string then here

local HttpService = game:GetService("HttpService")
local result1 = HttpService:GenerateGUID(true)
local result2
repeat wait() result2 = HttpService:GenerateGUID(true) until result2 ~= result1
if result2 ~= result1 then
-- code
end

What? no! the two guids will never be the same. if they manage to be the same, you should speak to guiness world records.

So is it like GenerateGUID never gets the same string in the same server, and math.randomseed sometimes gets it on the same server?

i just showed him an example of what he wanted.

Youre not understanding. GUIDs are not dependent on the server. You will never see two GUIDs being the same

Is Roblox’s UUID (GenerateGUID) system actually gaurenteed unique? - Help and Feedback / Scripting Support - DevForum | Roblox

This post actually states that wrong

You will legit never have to worry about them being the same because you are more likely to be hit by a metor than having two guids being the same. you do not have to implement code to insure that they are different.

sometimes you can get really unlucky

noo bro this is like a 0.0000000001% chance bro :sob::sob: if you spend a year generating 1000 guids a millisecond u will most likely not see one guid that is the same

There are 32 hex digits in a GUID, that is a 1 in 340282366920938463463374607431768211456 chance of a collision, which means for all intents and purposes, it will not happen

I am not sure that you understand probability. In the event that two GUIDs are the same roblox should be the least of your concerns, since you are now the luckiest human to ever exist. ever.

I still do not want to take a risk.

Let me clarify a bit more, I am trying to make a global shop and when a player sells an item, it will send to all server a UID, so the 1 in 103 trillion chance is more likely to occur

alr then you can try my code above.

NO ITS NOT BRO. :sob: With all due respect, you have to be an idiot to think that your game will see this occurring. It actually wont.

1 Like

Surely you are not understanding the magnitude of how rare this is.

It is much more likely that a gamma ray burst obliterates life on Earth this instant than it is to generate a duplicate UID.

Just look at Youtube video IDs, it has far less characters (11), wouldn’t you think that if this was such a big concern companies that big would be a little bit more worrying?

It’s not concerning at all, the numbers are just too big for you to understand the unlikeliness of such an event, especially considering that we’re not talking about the generation of an equal UID in the entirety of Roblox, just exclusively to your game.

2 Likes

Thx for explaining it in a much more politely way!
I guess I was being too over concerned

No worries, here’s some very dumbed down math that might help you get a glimpse of the problem.

A UID is a 32 character string consisting of both numbers and letters. There are 10 available numbers (including 0) for each slot and 26 available letters, if you count uppercase, that’s 52 available letters.

If you have a full-number UID, that would be:
1 in 10^32 chance
100.000.000.000.000.000.000.000.000.000.000

If you have a full-letter UID, that would be:
1 in roughly 8,16e+54 chance
81678357600369144882544181084627000000000000000000000000000000000000000000000000000000

These numbers might help you understand a little bit better of the magnitude we are talking about.

(late response :frowning: )

1 Like

I thought these GUIDs were represented by hex digits, so wouldn’t it only be 16 characters? (The end result is pretty much the same – a very low chance)