Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I make a individual ID system in Datastores?

What I'm trying to do Basically, I'm giving a value to every player(potentially for some choosing-systems). Every player will have a different value, with none of them being the same for each player.

TLDR: Every player that enters their own ID + checking system for every player in a datastore.

Some pseudocode Most likely it would be like(This isn't LUA or if anything, a actual code. Just pseudocode).

1. Check if player enters in.
2. Let player enter a value in/(or)/ choose random value..
3. Use datastores - get a list of every id.
4. Check through list if ID is in that datastore list/table
5. (Deny/Accept) player entry if ID is available.

I guess to dumb down the question would be "How would I create a table of datastores + add to it, and how would I find out whether a specific value exists in the datastore table?".

6 comments

0

Could you not just make a single datastore that stores every single userId?

0

It can work - but I'm mostly wanting to use random values for other purposes(potentially custom in-game names) et cetera.

0

Oh I get it. You could do something like, save everything with that custom ID, and then use the datastore to check if any data exists with that key. If not, then it is free.

0

Wait, so am I using the key as the id?

0

why not just load a character's settings by their name? like im not hugely familiar with data stores but you shouldnt have players entering a code, it would be better to have the changes applied to the character(s) by their name(s)

0

That's the thing - I'm not specifically looking to save data specific to the character. I'm looking to save data that can be accessed across servers or by myself later on in case I intend to do different features that would require a system like this(Like custom user names in game, or random drawing)

1 answer

You could use playerID. Each player has a unique ID. For example:

local ds = game:GetService("DataStoreService"):GetDataStore("user_"..player.userId)

ds:SetAsync(key, newValue)

This discussion is preserved as it was. New answers, comments, and votes are closed.