We use cookies on this site to enhance your user experience

Reset Player Data Store

Reset Player Data Store

Sep 05 2018, 8:10 PM PST

The following example is how you would generally use GlobalDataStore/SetAsync|SetAsync(). However, if more than one server will likely be writing to this key, it’s recommended that you use GlobalDataStore/UpdateAsync|UpdateAsync() instead.

local visitsDataStore = game:GetService("DataStoreService"):GetDataStore("PlayerVisits")

game.Players.PlayerAdded:Connect(function(player)
	local playerKey = "Player_" .. player.UserId
	local success, err = pcall(function()
		visitsDataStore:SetAsync(playerKey, 0)
	end)
end)