Remote function returning an error when a player disconnects from the game

Is there any way to solve this here?

Script:

_S.Players.PlayerAdded:Connect(function(player)
	while wait() do
		local _, position = GetMousePositionFunction:InvokeClient(player, {})
		print(position)
	end
end)

error:
image

1 Like

I think the problem is that every second you wan’t to get the mouse’s position, and repeating the process that many times probably times out the remote function.

1 Like

InvokeClient is generally bad practice as it can be exploited to hang the server if an exploiter purposefully causes an error

Why exactly do you need to print the position of the mouse every 1/30th of a second on the server when you can do it from the client via Localscript

That is a pretty expensive thing of handling stuff. Here’s what you could do:

  • Send the mouse’s position from the client to the server every frame render. Or if that still causes problems try this:
  • Every time the mouse’s position is needed for the server, fire it from the client

Information is kind of vague, I don’t know what else to suggest