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!
✓ ANSWER ACCEPTED
How to delete a DataStore key?
1 answer
✓ Accepted answer
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)
This discussion is preserved as it was. New answers, comments, and votes are closed.
