I want to delete some people's data in a Data Store because they exploited, I have admin commands but I could only change it if they were in a table. It's stored as a table so I'm not sure how I'd overwrite their old data with a empty data table. I want to completely delete if as if the player had never played before. I've tried:
game:GetService("DataStoreService"):GetDataStore("GameData"):SetAsync(tostring(62262419).."Data",nil)
But as I'm trying to set it to nil as if it had never happened it keeps returning the error 'Argument 2 missing or nil'. Is it possible to do this or will I have to produce a table of empty data just to reset his stats?
It depends on the key you made for them (the recommended key is "user" ..id
), but it's not too hard.
Your key is id.. "Data"
, correct?
Just make a table with their UserIds and iterate through it. So:
local plrs = {1,1232123,1337} -- etc. local ds = game:GetService("DataStoreService"):GetDataStore("GameData") for _,v in pairs (plrs) do ds:SetAsync(v.."Data",nil) -- the first parameter being the key, the second being the value end