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

Is it possible to set a key in a datastore to nil?

Asked by
ArtBlart 533 Moderation Voter
4 years ago
Edited 4 years ago

This isn't vital, as I already have a way around this but is there a way to reset a key in a datastore back to nil?

Since you can't pass nil to :SetAsync(), and :RemoveAsync() doesn't set the key's value to nil, is there any other methods to do so? Again this is out of pure curiosity, but if there is a way to do this I can definitely make optimizations to my datastore functions.

Thank you in advance.

0
What do you mean by an "index"? A datastore is a key-value store, there keys are made into strings even if you try to use numbers. RemoveAsync() removes the key, which means subsequent fetches will get nil for that key. I don't understand why you'd need to store "nil" and have this distinct from having no entry for that key. You can't really beat not storing the key at all as an optimization. EmilyBendsSpace 1025 — 4y
2
That's my bad. I did mean key, oops. But basically I have a BindableEvent set up to clear the data of the key passed to the event, and want to know if I can restore it back to nil just to make things a little cleaner in my script, as I am replacing the value with 0., and then when the data is loaded next, it checks for the 0 and if it's there, inserts the default data under the value. ArtBlart 533 — 4y

Answer this question