So, i often use remoteEvents for plenty of reasons, but is there an alternative? preferably one that als allows client to client and server to server communication.
for client-client or server-server use bindable events instead of remotes
I see, gonna check them out then.
Module scripts can be used to communicate between scripts, but there isn’t a single object that can do client-client and client-server.
ok, i have a question, so only 1 script at a time can use the event?
The darn OP confused me
BindableEvents are basically the opposite of RemoteEvents, nothing can change my mind on that
You can also use ModuleScripts as well I believe, since those are replicated across both the client & server
Not sure what you mean by that, but you can create as many functions as you want inside the ModuleScript
I havn’t really used them extensively myself I just know that they exist and used them a few times for simple stuff. But it seems like it according to the documentation
Bindable events → Server to Server
Remote Events → Client to Server / Server to Client
Module Scripts → Server1 to Server2 back to Server1 / Client to Server and back (kind of)
ModuleScripts do not transfer data across the client-server boundary.
that would be a remote function, or a double remote event
You are correct on the first 2, but the 3rd one, module scripts are “required” by other scripts, there is no second server.
When I say second server, its only if you have functions within the module that you pass data to.
--inside the server script
local module = require(myModule)
local sum = module.add(1, 3)
print(sum)
--inside the module script
local module = {}
module.add = function(num1, num2)
return num1 + num2
end)
return module
As you can see, you start with the server script (Server1) then pass data to the module script (Server2) then return a value back to the original server script (Server1). So its kinda Server1 → Server2 → Server1 (Kinda, i’m not sure how else to explain this)