If a player wants to start a new game, how would I delete their data in the datastore
Using DataStoreService
, the only way you can change a value is by overwriting
the former. The same thing applies with removing keys or values as well. Just like how you'd "remove" a variable in a script by setting it to nil
, you'd do the same thing in data store with whatever set method you're using (SetAsync
, UpdateAsync
, etc) - just save a nil value. Here's an example:
local data = game:GetService("DataStoreService"):GetDataStore("Test") data:SetAsync("Key", "Hello there") -- Assign a value wait(10) -- Keep the value for 10 seconds data:SetAsync("Key", nil) -- Essentially removing the value.
That's about it, simple as that. Let me know if you have any questions!