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

Can someone answer these DataStore questions?

Asked by 5 years ago

I have a couple of questions about DataStores. My first one is that the key for each player having a value, can the key have multiple values, or would you need to make a custom key name for each thing you want to save? The second question is that if you were to do some sort of inventory system, with datastores, let's say you wanted the value of a key to be the name of a weapon. Could you make the key value a stringvalue, so if you were to iterate through the players values and see if it matches with a tool name and clone it to their backpack?

0
Keys should be unique values if you're saving an individual player's values. They're commonly made into a string followed by the player's UserId, i.e. "Key_" .. player.UserId Gey4Jesus69 2705 — 5y
0
I couldn't fit my reply as a comment so i made it an answer. If you'd like a can show you my datastore script to give you an idea of how its generally set up. DinozCreates 1070 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Maybe im confused, but i think you are. What you're calling a 'key', is essentially just the players userId. Its used to differentiate between each players save data.

And the second part of your question, what you'd do in that situation is you'd save a table in the data store, you'd save the name of each weapon as a bool. If a player purchases the weapon turn the bool 'true', then have a separate function that on player connect give that player the weapon and add it to their starter pack.

Ad

Answer this question