Removing Data Help

Hello, so here is my script so far:

local dataStoreService = game:GetService("DataStoreService")
local timeData = dataStoreService:GetDataStore(script.DataStorageName.Value)

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local timeInGame = Instance.new("IntValue")
	timeInGame.Name = "Minutes"
	timeInGame.Value = timeData:GetAsync(player.UserId) or 0
	timeInGame.Parent = leaderstats

	timeInGame.Changed:Connect(function()
		timeData:SetAsync(player.UserId,timeInGame.Value)
	end)
	
	local timeReset = {
		player.leaderstats.Minutes.Value
		}
	
	player.Chatted:Connect(function(msg)
		if msg == "!RestartTime" then
			-- Remove all data Script here.
			end
		end)
end)

I’m not aware of how to reset everyone’s data depending if they’re in the server are not, but I’m trying to get it to whenever the player says “!RestartTime” everyone’s data clears, so where it says “-- Remove all data Script here”. Can someone tell me how I can write this script here to remove everyone’s data whether they’re in game or not.

Thanks for reading!

1 Like

If I am reading this right, you want to wipe them from the data store? Or do you want to reset the time? If you want to wipe them from the data store I suggest reading up on this:

I want to reset everyone’s times.

for _, plr in pairs(game.Players:GetChildren()) do
    plr:WaitForChild("leaderstats"):WaitForChild("Minutes").Value = 0
end

I know that, but is there a way I can reset everyone’s data even if they aren’t in the game.

1 Like

Oh you mean reset the data stores? You can just change the data store name.

Oh, alright. I’ll try that, thanks for the help.

1 Like