RemoteEvent & RemoteFunction Connections Don't Work Within Client Modules

Reproduction Steps
I’ve been able to reproduce the issue consistently by simply putting this code inside a module script’s function, and then calling it from a localscript:

RemoteEvent.OnClientEvent:connect(function() print 'Yep' end)
print 'passed line'

RemoteEvent can be pretty much anyways that replicates

If the server fires the event, nothing happens. However no errors are posted to the log and ‘passed line’ does print.

Expected Behavior
I expect to see ‘Yep’ in the client log everytime the remoteevent is fired from the server to the client.

Actual Behavior
Nothing happens, from all the testing I’ve done if you call OnClientEvent:connect from a module script it just doesn’t work. Same for remote functions.

If this behavior was consistent I wouldn’t consider it a bug, however OnServerInvoke and OnServerEvent connect under the same circumstances with no issue. It’s only the client side that can’t connect to a removeevent for some reason.

Issue Area: Engine
Issue Type: Other
Impact: High
Frequency: Constantly
Date First Experienced: 2021-07-14 05:07:00 (-04:00)
Date Last Experienced: 2021-07-14 06:07:00 (-04:00)

1 Like

Im not able to reproduce this. i’m pretty sure i followed the repro steps properly…

local module = {}

function module.test()
	game.ReplicatedStorage:WaitForChild("RemoteEvent").OnClientEvent:connect(function()
		print("fired")
	end)
	print("line passed")
end

return module

with the following modulescript function being ran from a localscript, i used FireAllClients on the server, and it seemed to run as normal. maybe you can provide a repro place?

4 Likes

Pretty sure that if this was widely happening that there would be hundreds of reports.
Any more information or code you can share?

2 Likes

yeah, a repro place file would be appreciated.

Hmmm I’ll see if I can make a repro place, I was reproducing this very consistently yesterday… maybe I forgot to include that the server and client are using the SAME module.

Well I was able to reproduce it under my circumstances, but now I feel kinda dumb because I didn’t notice the key cause of the issue yesterday… As a security measure, I put a localscript into the client from the server, then that localscript calls the module’s function, then the server destroys the localscript. This was to increase my network security by preventing exploiters from decompiling the network setup code.

Here’s what reproduces it, but now that I know the issue is the script being destroyed, I’m not sure why I would expect it to work in the first place xD. Repro.rbxl (29.7 KB)