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

[SOLVED] How do I delete a single user's data store?

Asked by 8 years ago

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?

0
You need a key for :SetAsync() Wutras 294 — 8y
0
What was the key? "user_" ..id ? TheDeadlyPanther 2460 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago

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
Ad
Log in to vote
2
Answered by 7 years ago

What the guy that answered said.

Answer this question