So i basically want to delete everything inside of my datastore key called “TwitterCodes” any help will be appreciated.
my code:
local datastore = game:GetService("DataStoreService")
local aDataStoreServer = datastore:GetDataStore("TwitterCodes")
local codelist = {
"Test",
"Test2"
}
game.Players.PlayerAdded:Connect(function(Player)
aDataStoreServer:GetAsync(Player.UserId.."-Code1")
aDataStoreServer:GetAsync(Player.UserId.."-Code2")
aDataStoreServer:GetAsync(Player.UserId.."-Code3")
end)
game.ReplicatedStorage.Redeem.OnServerEvent:Connect(function(Player, valueo)
if table.find(codelist,valueo) then -- Replace the Quotation text with your twitter code
if not aDataStoreServer:GetAsync(Player.UserId.."-Code2") then
aDataStoreServer:SetAsync(Player.UserId.."-Code2", true)
end
end
end)
Actually it is possible to delete all data by going through the list of async keys and removing each one. For warning this will delete all datastores for that game not an individual datastore if you had more than one datastore in the game.
I’d also scroll down a little bit in the community thread since some fixes were made to the code.
I mean thats not fully true. You can set all the values to nil and replace them to whatever you wish later. That way it doesn’t take up any space because its storing nothing. So do SetAsyc(key, nil) and those values will come up as nil. It technically won’t be gone but it definitely wouldn’t give you anything when calling on it until its changed.