Datastore2 wipe not working?

I followed the instructions on this post:

I went into the command bar and I put in the whole clear function, then I put in clear(110288389,“Scrizonn”). But my data is not being wiped?

Judging by the way the clear function reads out, “name” is supposed to be the name of the DataStore, not the player’s actual name. DataStore2 does not work in player usernames, it works in UserIds to avoid the username change debacle (and because you should be using UserIds for virtually any system that doesn’t require the display of the player’s username).

Instead of your own username, put in the name of the DataStore you are attempting to clear out data for. The UserId bit should remain the id of the user you’re trying to clear data for.

Hey, I just did clear(1102883891,“Wins”) and It worked once, but didn’t work for any other Id’s?

This is the script with the datastore name

local DataStore2 = require(1936396537)

local defaultValue = 0

game.Players.PlayerAdded:Connect(function(plr)
	local WinsDataStore = DataStore2("Wins",plr)
	
	local Wins = Instance.new("IntValue",plr)
	Wins.Name = "Wins"
	
	local function WinsUpdate(updatedValue)
		Wins.Value = WinsDataStore:Get(updatedValue)
	end
	WinsUpdate(defaultValue)
	
	WinsDataStore:OnUpdate(WinsUpdate)	
end)
``

The first argument should be the UserId of the player whose data you’re trying to clear out. If that works but not for another user, give it some time before you run the function again. You could be tripping DataStore limitations. It’s important to keep an eye on your console when something supposedly “doesn’t work” since your console will often explain the reason for that being the case.

The console says it’s finished, but doesn’t actually wipe it. Before when it worked on me it looped through all the keys and printed them, till it found mine. Output hasn’t said anything about reaching datastore limitations

35cfd1c42b75c9b22942f8571d5db93c

There may not be any data associated with the UserId you are attempting to wipe if the clear function is running successfully and there are no keys being submitted to the console. The clear function has a print statement that outputs any removed keys. If there are no keys, the page is empty; and an empty page will have nothing to be iterated over.

Is there still data associated with the user that doesn’t get cleared?

It depends on how data is being handled in the game or by DataStore2. That by all accounts should be considered normal since the function is intended for wiping data on players that won’t be joining again. For players that do, understandably it wouldn’t take immediate effect because DataStore2 caches data.

Alright, thanks for the help!

:slight_smile::grinning:

1 Like