Is there a way to return a remote event?

I’m trying to find a way if there is a way to return a remote event back to the client that fired it to the server. If you don’t understand what I mean, you can use this as an example of what I mean.

Client → Server → Client

You can’t return using RemoteEvents, the only way to return things through a remote is using RemoteFunctions. Example:

LocalScript

print(game.ReplicatedStorage.function:OnServerInvoke()) -- prints Hi

ServerScript

game.ReplicatedStorage.Function.OnServerInvoke = function()
     return "Hi"
end
1 Like

Is there a way that I can use a remote function and then fire a remote function from one player script to the server to a different player script?

I had that issue, this was one of the working solutions, you just tell the remote event to fire itself, and the script listening for the remote event will fire to the client then the other script will listen for the client fire.

1 Like

Utilize a RemoteFunction or use the RemoteEvent :FireClient(<Player>, ...) method.

1 Like

Like this:

LocalScript 1

game.ReplicatedStorage.Event:FireServer("hi")

ServerScript

local event = game.ReplicatedStorage.Event
event.OnServerEvent:Connect(function(player, string)
  event:FireClient(player, string)
end

LocalScript 2

local event = game.ReplicatedStorage.Event
event.OnClientEvent:Connect(function(string)
 script.Parent.Text = string -- text will show "hi”
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.