Is this better performance-wise?

Is having this kind of setup Request :arrow_right: Response using 2 remote events better than having 1 remote function?

LocalScript:

print("Starting at client")
game.ReplicatedStorage.RemoteEvent:FireServer()

game.ReplicatedStorage.OnClientEvent:Connect(function()
    print("Back to Client")
end)

Script:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
    print("Currently at server")
    game.ReplicatedStorage.RemoteEvent:FireClient(player)
end)

OUTPUT:

Starting at client
Currently at server
Back to Client

For this kind of passing, you should just use a remote function like this:

print("Starting at Client")
local returned = game.ReplicatedStorage.RemoteFunction:InvokeServer()
print(returned)

server:

game.ReplicatedStorage.RemoteFunction.OnServerInvoke = function()
    print("Currently at Server")
    return "Back to Client"
end

takes out the pain of writing more lines and also more connections.

I know that, but i’m wondering if having a module that simulates that kind of behavior would be better performance-wise please the post before replying.

Yes, as it consumes less memory from connections that would be used in that way.

Other known devs having this issue

1 Like