Another question about datastores

When a player leaves, this function is called

local function saveData(player)
	local playerUserId = player.UserId
	local success = pcall(function()
		playerData:UpdateAsync(playerUserId, function(oldData)
			return sessionData[playerUserId]
		end)
	end)
end

I’m wondering what would happen if the pcall would result into an error once a player leaves the game. Would it call UpdateAsync over and over again to try and get saved value back? (Note: I’m really new to datastores so apologies for the lack of understanding/knowledge about them)

If the function is called once, it will only run once. Therefore when it errors it won’t run again. If you want it to run again just say if error then saveData(player) return.

2 Likes