RemoteSignal:Connect() not working

Hello everyone. :slight_smile:
I have been working with the Knit framework lately and I have encountered an issue with the RemoteSignal library.
Basically, I create my service and insert my signal in the client table.

local InteractionService = Knit.CreateService { 
	Name = "InteractionService", 
	Client = {
		InteractionSignal = Knit.CreateSignal()
	},
}

Then I fire it later. This section runs (I have used breakpoints to test)

self.Client.InteractionSignal:FireAll(interactable, Module.Action)

I also have a controller (client-side module) that listens for this signal. This should also run. This is located in KnitStart.

local InteractionsService = Knit.GetService("InteractionService")
InteractionsService.InteractionSignal:Connect(function(Interactable, Action)
	Action(Interactable)
end)

I couldn’t find the issue so I edited a bit the RemoteSignal library to test everything.

function RemoteSignal:FireAll(...: any)
	print("Remote Signal Fired") --This is added.
	self._re:FireAllClients(self:_processOutboundMiddleware(nil, ...))
end
function RemoteSignal:Connect(fn)
	print("Remote Signal Connects") --This is added as well.
	if self._directConnect then
		return self._re.OnServerEvent:Connect(fn)
	else
		return self._signal:Connect(fn)
	end
end

The “Remote SIgnal Fired” is correctly printed when it’s supposed to fire.
However, the “Remote Signal Connects” does not prints.
Any solution? Thanks in advance. :grinning:

1 Like

I would imagine that the issue here is regarding your code that grabs the InteractionsService and then connects to the signal. Can you verify that the code there is definitely running? e.g. add some print statements around that code and verify it’s being run.

Also, wherever you are calling Knit.Start() on the client, do you have a catch clause attached to it to capture any errors? e.g.:

Knit.Start():catch(warn)

I didn’t have a catch clause before, but I added one now.

local KnitPromise = Knit.Start() --Used a variable since I also use andThen later.
KnitPromise:catch(warn)

However, it doesn’t return anything.
I have also used a print instead of a breakpoint right here

function InteractionController:KnitStart()
	local InteractionsService = Knit.GetService("InteractionService")
	
	print("Running")	
	InteractionsService.InteractionSignal:Connect(function(Interactable, Action)
		Action(Interactable)
	end)
end

And “Running” gets printed.
I have also tried to print the InteractionService instead of “Running”, here’s the result.
SĂ©lection_016
I can conclude that the client table gets sent properly, however, something does not work out with the connect.

I think the reason you don’t see a “Remote Signal Connects” message is because you put it in RemoteSignal, but it should be within ClientRemoteSignal instead.

Okay, I moved the print from RemoteSignal to ClientRemoteSignal and it prints! However, the connection is still not getting through. What is inside of the connect does not fire.

Can you add a print directly inside the connection handler function too? My concern now is that the Action argument is not being passed properly, since I’m not sure you can pass functions over remotes.

Added a print, still not working.

Are you by chance firing the event before the player actually joins the game?

Nope, when a ProximityPrompt is triggered (detected by the server), a signal is fired with FireAll, which should be received by the player.

Okay, I edited the ClientRemoteSignal ModuleScript once again.

function ClientRemoteSignal:Connect(fn: (...any) -> ())
	print("Event Connects")
	if self._directConnect then
		return self._re.OnClientEvent:Connect(function(...)
			print("Test")
			local args = {...}
			fn(args)
		end)
	else
		return self._signal:Connect(function(...)
			local args = {...}
			print("Test")
			fn(args)
		end)
	end
end

The “test” I am trying to print doesn’t print.

After some more testing, I have realized that this issue only occurs when trying to fire a Signal inside of another RBXScriptSignal, and the signal receiver is a controller.
The way I fixed it was simply by replacing my controller with a LocalScript.