Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Any way to receive a fired remote event from a client?

Asked by 4 years ago

Is there a way to detect a remote event being fired by a client from another client? Kind of like what a remotespy script does.

Client firing the event:

game.ReplicatedStorage.Event:FireServer(arguments)

Client 'sniffing' the event:

game.ReplicatedStorage.Event.Fired:Connect(function(arguments)

forgive me if this is a stupid question, new to scripting.

1 answer

Log in to vote
0
Answered by
oreoollie 649 Moderation Voter
4 years ago
Edited 4 years ago

No. Remotes only work from server to client and visa versa. The only way to allow two clients to communicate via remotes is to have the server relay the firing to the correct client. Here's an example of that: Sending client:

RemoteEvent:FireServer(plrToRelayTo, "Hi!")

Server:

RemoteEvent.OnServerEvent:Connect(function(plr, plrToRelayTo, msg)
    local sender = plr
    -- Optional logic to check if client is actually allowed to do this
    RemoteEvent:FireClient(plrToRelayTo, sender, msg)
end)

Receiving client:

RemoteEvent.OnClientEvent:Connect(function(sender, msg)
    print("From: " .. sender .. ": " .. msg)
end)

If my answer solved your problem please don't forget to upvote and accept it.

Ad

Answer this question