Event clones itself

Hello developers!
Today I noticed something really weird about Remote Events.
I fired one event to each of 2 people. There were 5 people on the server.

image

Event was received only by the people who were supposed to get it.
But instead of receiving it once, they received it many times.

image

Based on brief tests, I conclude that the number of events that player receive is the number of people on the server. I think it’s an engine bug but I’m not sure. Is it somehow possible to avoid this?

Code on the server:

for i,v in pairs(Employees.Maintenance:GetChildren()) do
	print("Sent to "..v.Name)
	Events.ExecTask:FireClient(Players:FindFirstChild(v.Name), Name, Obj)
end

Code on the client:

Events.ExecTask.OnClientEvent:Connect(function(Name, Obj)
	print("Received")
end)

I had this bug when using a script with its run context set to client, if you are doing that you can work around it by using a localscript instead.

1 Like

I tried, but using the local script I receive nothing from the server.

Where is the script located?

1 Like

It was here

image

When I moved it here, it started working

image

Location of the script was a problem.
Thanks for your help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.