When they press a button, you will fire a RemoteEvent from that client to the server, assuming you’re working with GuiButtons. The server will have to default all values, and you can call RemoveAsync on the datastore to remove the player’s data from the datastore
That’s a LocalScript, right? You can’t alter DataStores from the client. (That would be a big security risk!)
-- This assumes you have a RemoteEvent in ReplicatedStorage named EraseData
-- Client script
---------------------
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.EraseData:FireServer()
end)
-- Server script
-----------------
-- This assumes you've declared the var DataStore as the store you've been using
game.ReplicatedStorage.EraseData.OnServerEvent:Connect(function(Player)
local Key = Player.UserId -- or whatever you've been using to store play data
DataStore:RemoveAsync(Key)
end)
Yes, that would effectively reset as well. However, he stated in the OP that he wants to erase data (not just set to default) so that’s what I answered.
For example, handling a Right to Erasure request is not satisfied by simply resetting, but you need to fully remove it.
Removing the key and setting it to zero are two different circumstances. In some cases where your DataStore handler is expecting a nil value for no data, a 0 value would produce unintended results and create errors in your code.
RemoveAsync is the proper way to erase and remove a player’s data, not setting it to a different value.