Automate the creation of RemoteFunctions/Events when flagged as one in script

Usage:

SERVER:
function ReplicatedFunctions.buyItem(player)
code here
end

CLIENT:
ReplicatedFunctions.buyItem()

And thats it. No need to spend time creating ReplicatedFunction instances. Basically whenever a function is assigned to the ReplicatedFunctions global table, a corresponding ReplicatedFunction is created. When the client attempts to index the same table clientside, if the replicatedfunction with that name exists, a proxy function is returned (that calls the replicatedfunction and passes the params)

Of course would work other way around too (defining functions clientside)

This can of course be implemented using modulescripts, just made this:

(only supports remotefunctions, the ReplicatedFunctions table is returned when the module is required)

However since the point is ease of use, having to require at the top of the script is not good. Additionally, performance might be a concern since everything goes through proxy functions and stuff.

It might be good to not have a global ReplicatedFunctions table, but instead have one table per script (avoiding conflicts).
So instead of:
ReplicatedFunctions
You type:
game.ReplicatedStorage.MuhScript:GetRemoteState()
or similar.
(I named it state because I guess this could very easily be made to also provide access to variables, not just functions)

This is pretty much just a different way to do remotefunctions, but I like it more than the current way because its not necessary to create a new instance for every function you want to make remotely callable.

Wachoo think?

“However since the point is ease of use, having to require at the top of the script is not good.”

I think that you’re wrong about that. The few keystrokes you save by not having to type out the require in the scripts you need it are not worth the loss of simplicity, flexibility and elegance of using a plain old require for it.

Just type out the require, it’s not that big a deal and it makes everything work much better.

But my code is ugly and I want roblox to make an official version o3o

I think that a well coded module is easily sufficient for this problem. I’ll make one if you really don’t like your own solution to the problem.

Mine isnt really a full solution (lacking support for remoteevents and not being too reliable), I just wanted to see if its possible to implement it as a modulescript.

I dont need one personally, I just thought it might be nice to have something like it around for projects where the amount of remote____ instances requires is high. Especially when they mostly deal with small tasks.

“Especially when they mostly deal with small tasks.”

If you design your network communication well then there should actually be a pretty small number of RemoteFunction/Events necessary. Really you should be grouping common protocols together. Like, you shouldn’t have a separate “OpenDoor” and “RaiseDrawbridge” remote, they should be a common protocol like “SetPassable(Object gateway, bool state)” for all open / closeable “gateways” between parts of your level.