Strange Remotevent error

Hi I have the following code for server and client scripts:

Server:

local remoteEvent = game.ReplicatedStorage:WaitForChild("ToggleProximity")

while wait() do
	for _, plr in ipairs(game:GetService("Players"):GetPlayers()) do
		local isPartOfTeam = (plr.Team == teams["King"]) -- returns either 'true' or 'false'
		remoteEvent:FireClient(plr, isPartOfTeam)
		
		if plr.Team == teams.King then
			for _, tool in pairs(plr.Backpack:GetChildren()) do
				if tool.NumberValue.Value == 0 then
					kingPieces.Value = "0/3"
				elseif tool.NumberValue.Value == 1 then
					kingPieces.Value = "1/3"
				elseif tool.NumberValue.Value == 2 then
					kingPieces.Value = "2/3"
				elseif tool.NumberValue.Value == 3 then
					kingPieces.Value = "3/3"
				end
			end
		end
	end
end

Client:

local remoteEvent = game.ReplicatedStorage:WaitForChild("ToggleProximity")

remoteEvent.OnClientEvent:Connect(function(isVisible)
	-- get the proximity prompt and make it visible depending on the 'isVisible' parameter
	if workspace:FindFirstChild("Map") and workspace.Map:FindFirstChild("Palace") then	    
		for i, descendant in pairs(workspace.Map.Palace:GetDescendants()) do

			if descendant:IsA("Tool") and descendant:FindFirstChild("Handle") and not game.Players:GetPlayerFromCharacter(descendant.Parent) then
				descendant.Handle.ProximityPrompt.Enabled = isVisible

			end
		end
	end

end)

And I get the following list of errors:

  23:05:02.755  Remote event invocation queue exhausted for ReplicatedStorage.ToggleProximity; did you forget to implement OnClientEvent? (1 events dropped)  -  Studio
  23:05:02.755  Remote event invocation queue exhausted for ReplicatedStorage.ToggleProximity; did you forget to implement OnClientEvent? (2 events dropped)  -  Studio
  23:05:02.755  Remote event invocation queue exhausted for ReplicatedStorage.ToggleProximity; did you forget to implement OnClientEvent? (4 events dropped)  -  Studio
  23:05:02.755  Remote event invocation queue exhausted for ReplicatedStorage.ToggleProximity; did you forget to implement OnClientEvent? (8 events dropped)  -  Studio
  23:05:02.755  Remote event invocation queue exhausted for ReplicatedStorage.ToggleProximity; did you forget to implement OnClientEvent? (16 events dropped)  -  Studio
  23:05:02.755  Remote event invocation queue exhausted for ReplicatedStorage.ToggleProximity; did you forget to implement OnClientEvent? (32 events dropped)  -  Studio
  23:05:02.755  Remote event invocation queue exhausted for ReplicatedStorage.ToggleProximity; did you forget to implement OnClientEvent? (64 events dropped)  -  Studio
  23:05:02.783  Remote event invocation queue exhausted for ReplicatedStorage.ToggleProximity; did you forget to implement OnClientEvent? (128 events dropped)  -  Studio
  23:05:04.333  Remote event invocation queue exhausted for ReplicatedStorage.ToggleProximity; did you forget to implement OnClientEvent? (256 events dropped)  

And yes I have the remote event named correctly in replicated storage, Any ideas what could be causing it?

In your first script, you are sending a network update every frame through a remote event.

RemoteEvents are intended for notifying clients of infrequent (no more than a few invocations per network frame) events that occur in the game. They come with guarantees with ordering and delivery; the remote event invocations you fire should arrive at the destination in order, and if some data is dropped, the message will be retransmitted until the player either receives the message or is disconnected.

To do this, remote events have an internal message queue. This is a data structure that keeps track of all the messages that need to be sent in the current network frame. There is finite space in this internal queue.

Assuming wait() yields for only 0.05 seconds, that means you are sending 20*playerCount messages per second. That means if you have 8 players in the game, you are sending 20*8=160 messages per second through a remote event. This is an overwhelming amount of data, even for client connections. This not only throws the error you describe, but it’s also likely this code would saturate and choke every connection and thus interfere with other RemoteEvents / replicated instance updates.

I don’t have the full context of your code, but it looks like you are writing code to show or hide something depending on the player’s team. This is something you can do entirely on the client without a remote event. The player’s team is a property that is automatically replicated by Roblox’s internal replication system, so you should just be able to read the player’s team without this inefficient remote event.

If you have values in your game that you must change and replicate every frame, you should first try to see if there are any ways to avoid doing this. This is highly inefficient from a network overhead standpoint, and if you can get away with just transmitting the changes in the data (This is called delta transmission) or figuring out what the value should be based on info that already exists on the client, you should consider taking those routes first. If there is no other choice, use a Value instance instead. Roblox’s internal replication code for instances is built for dealing with values that are constantly changing, and this will give you the biggest bang-for-your-buck in terms of performance.

4 Likes

Thank you so much for the informative comment that really does help a lot not only with this but with other areas aswell, so thank you!

1 Like