Remote Functions Method Overriding

So my team and I have set up a general network framework that we’re using for our game, and we’re trying to have one RemoteFunction and one RemoteEvent and a module that will parse and handle all requests, listeners, and events that are being fired.

--Function to listen for when the server is invoked from the client
function net.onServerInvoke(identifier, callback)
	-- initiailize our on invoke function, passing the necessary arguments
	function remoteFunction.OnServerInvoke(player, newIdentifier, packet)
		-- make sure the invoked identifier matches the listener's identifier
		if (newIdentifier:upper():match(identifier:upper()) ~= nil) then
			-- call the callback and return its return value
			return (callback(player, packet, identifier, newIdentifier))

The onServerInvoke function is called once on the server, and everytime it’s called it creates a new listener and connects a function,this new function takes the identifier that was sent from the client and it compares it to the identifier that was passed from the onServerInvoke function

not sure if I explained properly but basically its a check to ensure that the client is invoking the right listener

then from there, the callback passed from the server is executed and returns its value

here’s what it looks like

appearance.Role = NetworkClient.invokeServerAsync("RetrieveNation")


--Returns the player's nation when invoked
NetworkServer.onServerInvoke("RetrieveNation", function(player)
	return globalDataList[player.Name]["Configuration"]["Nation"]

Now here’s the issue, I’ve set up two listeners on the server to receive both the role and nation but the issue is that it seems that every time I connect onServerInvoke to the same single remote function it seems like it overrides the previous listener, which I wasn’t sure why because they both take different identifiers and arguments… maybe it’s method overriding? I don’t know but is there a workaround to this without using multiple remote functions?

I’d like to avoid using coroutines as well because that seems to create a completely new thread that does not have reference to the variables in the main thread

RemoteFunctions are not the same as RemoteEvents.

RemoteEvents gives you a Signal, and RemoteFunctions calls a function, well, you can only assign one function to a RemoteFunction.

A solution, the RemoteFunctions calls a function, which calls other functions, you can store these functions with some key and call the RemoteFunction with that key.

1 Like

Ahh I see what you mean, alright I’ll give it a go

Ayeee it worked, thanks bro much love bless up

1 Like