It wouldn’t cause server lag since the function would run on the client instead of the server, but it will take some cpu to call the function, but again just on the client.
We can’t answer this without knowing the contents of MyFunction.
If the listener itself uses a lot of processing power then, yes, stress on the server will noticeably increase with more firing—the fact that the function is being used as a listener doesn’t necessarily impact this, though. Calling a not-so-performant function a lot in any context will cause performance issues.
On the other hand, if the listener doesn’t do much, you won’t have any issues.
local function OnServerEvent(Client, Data)
for i,v in ipairs(Players:GetChildren()) do
if v ~= Client then
RouterFolder[Client.UserId]:FireClient(v, Data)
end
end
end
for i,v in ipairs(RouterFolder:GetChildren()) do
v.OnServerEvent:Connect(OnServerEvent)
end
(I’m currently working on the authentication of the data and some sort of delay)
The function itself is fine performance-wise, but firing every client when one client fires a remote and passing whatever the original client gave you to the other clients could cause some latency issues if abused.
A malicious user could repeatedly fire the remote with a large piece of data each time, and have every client sent the same large piece of data to them. This will take up a lot of bandwidth.
But also remember that network frequency is less than framerate. In other words, it’s kinda pointless to call a RemoteEvent every frame. If I have to constantly fire RemoteEvents, I usually do it at a frequency of once per 0.1 seconds (10 a second), since a 100ms ping is probably pretty common among most users.
That being said, you could also get fancy and try to measure the latency and then adjust the delay based on that—but that’s kinda overkill, since it will just queue automatically for you.