X Bridge is a fairly simple system that I find myself using a lot.
It allows you to funnel client-server communication through a single RemoteFunction.
Pros
- Code is more legible
- Faster developing
Cons
- X Bridge does not support RemoteEvents
ā If you want to squeeze out that extra performance, you can always manually make RemoteEvents. If this module gets popular, I might add something for this in the future
So how does it work?
Iām glad you asked.
X Bridge consists of two modules.
One module for the server side and one module for the client side.
The server side module returns a function formatted like this
ServerSide(array table_of_functions)
The functions inside the array should be formatted like this
function_name = function(player caller_player, variable1, variable2, variable3, etc.)
The client side module returns a function formatted like this
ClientAccess(string name_of_function, variable1, variable2, variable3, etc.)
Usage
In a server script, you can do something like this:
-- Server Script
GiveClientAccess = require(game.ServerStorage.ServerSide)
insecureFunctions = {
test = function(Player,Brick_Color)
Brick_Color = Brick_Color or BrickColor.Black()
print(Player.Name..' wants to spam '..tostring(Brick_Color)..' parts!')
spawn(function()
while wait(.25) do
Instance.new('Part',workspace).BrickColor = Brick_Color
end
end)
return true
end
}
GiveClientAccess(insecureFunctions)
Once you have done that, you can call this function through the client side by doing something like this:
-- LocalScript
RequestServerFunction = require(game.ReplicatedStorage.ClientAccess)
firstRequest = RequestServerFunction('test')
print('First request returned',firstRequest)
secondRequest = RequestServerFunction('test',BrickColor.Red())
print('Second request returned',secondRequest)
Writing code this way makes it very intelligible.
Gone are the days of messing around with RemoteFunctions!
Feel free to reply with any critiques or suggestions.