I have a problem

So i made an alogritnm which sorts players from first to last player:
–Isnt pretty coded like this just an example what i mean
ds:GetAsync(54,plr.Userid)
ds:GetAsync(55,plr.Userid)
ds:GetAsync(56,plr.Userid)
, now i have the problem how i can detect if this player exists in another key, do you have an idea how to solve it or a better solution for this?

1 Like

I’m not sure I completely understand what you mean. Why not just use one datastore per player (ds:GetAsync(plr.UserId))?

1 Like

Wait i spelled it wrong, let me correct it:
ds:GetAsync(plr.Userid,54)
ds:GetAsync(plr.Userid,55)
ds:GetAsync(plr.Userid,56)

so basiclly i made an algoritm which gives them a special ingame id, but how can i search in the whole data store a plr,which has a special ingame id?

1 Like

if this player exists in another key

what do you mean by this exactly?

if you are trying to look for a specific player who is in-game in a specific server, consider using MessagingService.

1 Like

what do you mean???

1 Like

if you want a special id, you can use UUIDs (Universally Unique Identifier)
what’s special about this is that it takes millions of years to generate two identical id!

you can generate a UUID/GUID using HttpService:GenerateGUID()

-- Example
local HttpService = game:GetService("HttpService")

local firstId = HttpService:GenerateGUID(true)
print(firstId) --> {94b717b2-d54f-4340-a504-bd809ef5bf5c}

local secondId = HttpService:GenerateGUID(false)
print(secondId) --> db454790-7563-44ed-ab4b-397ff5df737b

-- notice that they're not the same? me too!

it would be optimal if its listed after numbers 1,2,3,4,5,6…6543… else i need to change my other script which could take many time

1 Like

you could use math.random() or Random.new():NextInteger() but it’s less effective because it has a higher chance of generating two identical numbees in a short period of time depending on the number of digits and seed.

-- Example

local randomNumber = math.random(1, 9999)
-- the number of 9s is the maximum number of digits that can be generated

-- the same as
local randomNumber2 = Random.new():NextInteger(1, 9999)