New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
Log in to vote

What is the Value of a newly created Data Store?

Asked by 4 years ago

When a player joins and you use :GetDataStore() I believe it will create the new one with the name inside. So, now that a new DataStore was created i'll call it Storage for this question. The Key of Storage will be the name you put in :GetDataStore() , so what will its value be? Will the value be nil or will it be 0 ?

I'm asking because say I wanted to see if this is a new DataStore, I want to check to see if they have the new starting value and if so, change is using :SetAsync() so the value will be something that'll probably give starting gear in another script (This is not what i'm accomplishing, i'm making this up to show what I mean).

So again, What's the Value for a newly created Data Store?

1 answer

Log in to vote
Answered by
BlueTaslem 17577 Moderation Voter Administrator Community Moderator Super Administrator
4 years ago

From Data store article on the Wiki1


Returns the value of the entry in the DataStore with the given key. If the key does not exist, returns nil. This function caches for about 10 seconds: you cannot be sure that this function returns the actual value saved on the roblox servers.

It wouldn't make sense for it to return 0, since it doesn't know you'll expect a number (most things saved are probably not numbers) -- unlike data persistence, you don't ask for a type of thing, just give where it is.

  1. References like the Wiki are your friend! 

Oh, I should have noticed that, lol. Where do you figure out all of the things to add in an answer? Like, their are Dots i've seen you do and so on that make it look better, how do you know them? alphawolvess 1699 — 4y

Answer this question