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

How to delete a DataStore key?

Asked by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

Hey all! I was wondering how to delete a DataStore key. Let me be a bit more specific, in case you are confused. Let's say I saved a table with DataStores, that consisted of several tables (Let's say one of those tables is named "Name"). How would I delete "Name"? Not just clear it by making the table blank, but actually deleting the table? Thanks!

1 answer

Log in to vote
1
Answered by
ImageLabel 1541 Moderation Voter
9 years ago

Set the key in which the table is contained to nil.

DataStore:SetAsync(key, nil)

If the table you are trying to remove is nested within another, you could get the value, create a new variable to reference it -- because you cannot directly edit the table returned by GetAsync, and finally setting whatever you need to nil.

local got = DataStore:GetAsync(key)
local reference = got

reference['Name'] = nil

DataStore:SetAsync(key, reference)
Ad

Answer this question