I’ll try to keep things nice and simple while explaining in detail what I’m looking for.
I would like to use BindableEvents or a custom implementation to create a signal, like the ones that Roblox instances have (e.g. BasePart.Touched). Replication would be included with these signals. Below is a table that shows what kind of workflow I’m looking for.
Machine | Can connect | Can fire |
---|---|---|
Server | Yes | Yes |
Client | Yes | No* |
*If I can’t restrict firing from the client, restrictions apply. I explain that further down.
In my codebase, usage of the signal would look like this:
-- Server and client method
Signal:Connect(FunctionBody)
-- Server-only, client w/ restrictions
Signal:Fire(Arguments)
To explain the above table in bullet points, this is what I’d like:
- Server and client can connect to signal
- Server can fire signals: all connections (server and client) will run
- Client cannot fire signal
- If they can, then only client connections should run (I can just use BindableEvents here)
You can’t do all this with vanilla BindableEvents because sending and receiving is restricted to a specific environment. Any events connected by the server will only run when the server fires the bindable, likewise for the client. For a custom signal class it’s the same way because each machine (server and clients) have different copies of a ModuleScript returned on require.
I do not want to resolve this task using either RemoteEvents or ValueObjects Please do not suggest their use. If I have no choice in the matter, I’d like to know why their use is needed and how I can implement them invisibly both as a developer and at run time for scripts in the game.
And I suppose the final thing to include is the why.
-
I would like to create a mock of Roblox’s instances signals for custom objects. This will help out creating replicating events for pseudoinstances (class objects made from a new method).
-
I feel like it’d be easier, cleaner and widely useful to be able to connect to a signal from both environments but limit firing across one environment, or replicate a fired signal from the server across the server as well as to clients.
-
Imagine the joys you could get out of, for example, a ValueObject-less data management system. The client could connect to a signal determing when updates are made to update some Guis and the server could as well to push new data to the cache, replicate or use for other functions.
-
I love code organisation a little too much.
This sounds like something that would involve selective or developer-controlled replication, so if I can’t do it without either of these being a feature, then I’ll be sad and wait until it is. No feature request because this has already been asked for numerous times.
The closest solution I’m looking at is HuotChu’s PubSub. It uses remotes internally which I don’t want. This is also 2 years old, the source can be improved and it has undesirable conventions. It’s my last resort as of right now.
(10/24/19 - 1:03AM) Cleaned up the post a bit. Hopefully it’s easier to follow now.