Resetting the player's save data

So, I wanted to make a button that resets the user’s save data,
so I made a script that saves nil.

But here is the problem, when ever I run this code,
it says “Argument 2 missing or nil” in the output,
now I understand what this error means,
but I was wondering if there was any way to save nil,
or is it just inpossible?

I haven’t really tried anything since I couldent come up with anything.

:small_red_triangle_down: Here is my code :small_red_triangle_down:

local DataStoreService = game:GetService("DataStoreService")

local CoinsSave = DataStoreService:GetDataStore("CoinsSave")
local MainToolsSave = DataStoreService:GetDataStore("MainToolsSave")
local TotemsSave = DataStoreService:GetDataStore("TotemsSave")

local Player = script.Parent.Parent.Parent.Parent.Parent

script.Parent.Yes.MouseButton1Click:Connect(function()
	CoinsSave:SetAsync(Player.UserId, nil)
	MainToolsSave:SetAsync(Player.UserId, nil)
	TotemsSave:SetAsync(Player.UserId, nil)
end)

If you have any solution to this, or an idea, please tell me. Thank you!
(Also I am japanese, so my grammer might be very incorrect, if it is, then I am very sorry.)

You’ll want to use GlobalDataStore | Roblox Creator Documentation.

I also recommend putting all data in one data store, then saving things under a table. 3 separate data stores is a very bad idea and will most likely lead to data loss due to high data store requests.

1 Like