Fire a remote event and call a function at the same time the player leaves

Hello,

I have a function that fires when a player leaves. It calls another function to save.
I tried to fire a remote event before or after the save function is called. Roblox Studio got piled with errors from roblox core scripts. I also tried separating them into two scripts, which also got the same result.

The remote event only fires a small string and the player removing object.

How can I not get all these errors?

Could you paste the relevant code, hard to debug without knowing exactly what you’re doing

game.Players.PlayerRemoving:Connect(function(player)
	save(player)
        game.ReplicatedStorage.RemoteFunction:FireAllClients(player)-- this is what messes it up
end)

function save(player)	-- normal datastore plugin
	local sucess, err = pcall(function()
		workpoints:SetAsync(tostring(player.UserId),player.leaderstats.WorkPoints.Value)
	end)	
end

Could you also post the errors roblox is throwing? It is quite normal to get some roblox corescript errors in studio testing. I usually get some ‘Unable to load asset’ errors due to a faulty connection.

Roblox is who you would have to ask for all those errors. We all live with it and it doesn’t cause any problems…