Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I make a individual ID system in Datastores?

Asked by
3dsonicdx 163
8 years ago

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?".

0
Could you not just make a single datastore that stores every single userId? NoahWillCode 370 — 8y
0
It can work - but I'm mostly wanting to use random values for other purposes(potentially custom in-game names) et cetera. 3dsonicdx 163 — 8y
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. NoahWillCode 370 — 8y
0
Wait, so am I using the key as the id? 3dsonicdx 163 — 8y
View all comments (2 more)
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) dragonkeeper467 453 — 8y
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) 3dsonicdx 163 — 8y

1 answer

Log in to vote
1
Answered by
Csharp0 10
8 years ago

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)
Ad

Answer this question