Guide: Watching remotes

Seeing what a game sends to the server, sending it yourself, and looking at the raw packets.

Why bother

Pretty much everything important a game does goes through a RemoteEvent or RemoteFunction. Watching that traffic shows you what the server expects, which is the difference between guessing and writing a script that actually works.

You can do it at three levels, easiest to hardest: hook __namecall, look at the signal's connections directly, or hook RakNet packets.

A namecall spy

The same hook from the hooking guide, cleaned up into something you'd actually leave running.

spy.lua
local old
local logging = true

old = hookmetamethod(game, "__namecall", newcclosure(function(self, ...)
    local method = getnamecallmethod()

    if logging and not checkcaller() then
        if method == "FireServer" or method == "InvokeServer" then
            local args = {...}
            rconsoleprint(("[%s] %s\n"):format(method, self:GetFullName()))
            for i, v in ipairs(args) do
                rconsoleprint(("  [%d] %s = %s\n"):format(i, typeof(v), tostring(v)))
            end
        end
    end

    return old(self, ...)
end))

rconsolecreate()
rconsolesettitle("remote spy")

Log to rconsole, not print

A busy game will flood the editor console faster than you can read it. An rconsole window scrolls on its own and stays visible.

Firing them yourself

Once you know what a call looks like you can make it yourself. For stuff going to the server, just call the remote. For *client* signals (the ones the server fires at you), firesignal runs the handlers locally without touching the network.

fire.lua
local remote = game:GetService("ReplicatedStorage"):WaitForChild("Buy")

-- Server-bound: a normal call.
remote:FireServer("sword", 1)

-- Client-bound: run whatever the game connected, locally.
local incoming = game:GetService("ReplicatedStorage"):WaitForChild("Reward")
firesignal(incoming.OnClientEvent, 500)

-- Or inspect the connections instead of firing blind.
for _, connection in ipairs(getconnections(incoming.OnClientEvent)) do
    print(connection.Function, connection.State)
end

getconnections gives you the actual handler functions, and you can pass those to debug.getupvalues to see what they captured. cansignalreplicate tells you if a signal can be sent back over the network with replicatesignal.

Going lower with RakNet

Under the remotes are the actual packets. raknet.add_send_hook gives you every outgoing packet before it's sent, with its id, data and reliability, and lets you block it.

raknet.lua
local hook = raknet.add_send_hook(function(packet)
    -- Log the id and size of everything leaving.
    print(("id=%d size=%d channel=%d"):format(packet.Id, packet.Size, packet.OrderingChannel))

    -- Drop a specific packet type entirely.
    if packet.Id == 83 then
        packet:Block()
    end
end)

-- ... later
raknet.remove_send_hook(hook)

Blocking packets breaks stuff

The client and server expect to stay in sync. Drop the wrong packet and you get desynced, kicked or worse. raknet.desync is there for when you actually want that, on purpose and for a short time.

See also

Signals for firesignal, getconnections, replicatesignal and connection objects, Metatable for the namecall hook, RakNet for packets, and Console for the rconsole stuff used above.