Unexpected event handling for RemoteEvent s

Hey guys,
I am having a hard time understanding the RemoteEvents behaviour.

Lets say you have a RemoteEvent and invoke the FireClient from your server
if the client is not registered to handle this event nothing happens (as expected).

But when you decide to listen this RemoteEvent much later than those FireClient calls
You get all the previous events right after registering the event handler on your client.

This can be simply simulated by instantly firing events on server and
making the client wait a couple of seconds before registering the handler

-- Script in Server
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local RemoteEvent = ReplicatedStorage.RemoteEvent 

Players.PlayerAdded:Connect(function(player)
	
    RemoteEvent:FireClient(player, "A");
    print("Server fired RemoteEvent with data: A")
    
    RemoteEvent:FireClient(player, "B");
    print("Server fired RemoteEvent with data: B")
    
    RemoteEvent:FireClient(player, "C");
    print("Server fired RemoteEvent with data: C")
    
    wait(15)
    
    RemoteEvent:FireClient(player, "D");
    print("Server fired RemoteEvent with data: D")
end)


-- LocalScript in Client
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
print("Client will wait for 10 seconds before registering event handler")
wait(10)
RemoteEvent.OnClientEvent:Connect(function(parameter)
    print("Client has received the event " .. parameter)
end)

In this case i only expect the event D to be processed by client but all the events
(A,B,C,D) are processed.

Is this a bug or a feature?
Does anyone know why do RemoteEvents work like this?

Here is the timeline of the situation that i am trying to explain

You can also try this with this roblox project
RemoteEventBehaviour.rbxl (22.2 KB)

3 Likes