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?
From Data store article on the Wiki1
GetAsync(key)
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.
References like the Wiki are your friend! ↩