--[[
▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄ ▄▄▄
███ ███▀▀▀▀▀ ████▄████
███ ███▄▄ ▀█████▀
███ ███ ▄███████▄
████████ ▀███████ ███▀ ▀███
+------------------------------------------------+
| LEX REMOTE SPY TOOL :: |
| MADE BY LEX |
| VERSION: 0.1.1 |
| Open Source |
+--------------------------------------------+
--]]
local env = getgenv and getgenv() or _G
if env.__LEXSPY_CLEANUP then pcall(env.__LEXSPY_CLEANUP) end
env.__LEXSPY_LOADED = true
local t0 = os.clock()
local Players=game:GetService('Players')
local RunService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local RS=game:GetService("ReplicatedStorage")
local CoreGui = game:GetService("CoreGui")
local TS = game:GetService('TweenService')
local plr = Players.LocalPlayer
local TAG = "[Lex Remote Spy] "
local unpack = table.unpack or unpack
local function isfn(f) return type(f) == "function" end
local can={
hooks = isfn(getrawmetatable) and isfn(getnamecallmethod),
setnc = isfn(setnamecallmethod),
readonly=isfn(setreadonly),
cclosure = isfn(newcclosure),
cbvalue=isfn(getcallbackvalue),
writefile=isfn(writefile),
folders = isfn(isfolder) and isfn(makefolder),
loadstr = isfn(loadstring),
fire=isfn(firesignal),
hui = isfn(gethui),
}
local function weak() return setmetatable({}, {__mode = "k"}) end
local remFolder = RS:FindFirstChild("Remotes")
local isBB = remFolder ~= nil and remFolder:FindFirstChild("ParryButtonPress") ~= nil
local S={
on = true,
paused = false,
dir = "All",
query="",
bbOnly = false,
autoscroll = true,
cap=600,
log = {},
nextId = 1,
sel = nil,
blocked={},
ignored={},
dirty=true,
maxQueue = 5000,
muted=weak(),
listeners=weak(),
nListen = 0,
wrapped = weak(),
conns = {},
hooked=false,
dead = false,
}
local BB_NAMES = {
ParryButtonPress = "Parry Request",
AbilityButtonPress = "Ability Request",
ParrySuccess = "Parry Success (server → client)",
ParryFailed = "Parry Failed",
ActivateSuper="Activate Super",
DefensiveMove = "Defensive Move",
TeleportToStandardGame = "Teleport To Standard Game",
Emotes="Emotes Remote",
}
local function friendly(path)
if not path then return end
for key, label in pairs(BB_NAMES) do
if path:find(key, 1, true) then return label end
end
end
local function buildPath(inst)
local chain = {}
local p = inst
while p and p ~= game do
table.insert(chain, 1, p)
p = p.Parent
end
if p ~= game or #chain == 0 then return nil end
local out, from
if chain[2]==plr then
out='game:GetService("Players").LocalPlayer'
from = 3
else
local root=chain[1]
local svc = false
pcall(function() svc = game:GetService(root.ClassName) == root end)
if svc then
out = ("game:GetService(%q)"):format(root.ClassName)
else
out = ("game:WaitForChild(%q)"):format(root.Name)
end
from = 2
end
for i = from, #chain do
out = out .. (":WaitForChild(%q)"):format(chain[i].Name)
end
return out
end
local function pathExpr(inst)
local ok, res = pcall(buildPath, inst)
if ok and res then return res end
local cls, nm = "Instance", "?"
pcall(function() cls, nm = inst.ClassName, inst.Name end)
return "nil --[[" .. tostring(cls) .. " " .. (tostring(nm):gsub("%]%]", "] ]")) .. " (not in game)]]"
end
local OTHER = {
BrickColor = function(v) return ("BrickColor.new(%q)"):format(v.Name) end,
UDim = function(v) return ("UDim.new(%.4f, %d)"):format(v.Scale, v.Offset) end,
Rect = function(v) return ("Rect.new(%g, %g, %g, %g)"):format(v.Min.X, v.Min.Y, v.Max.X, v.Max.Y) end,
NumberRange = function(v) return ("NumberRange.new(%s, %s)"):format(tostring(v.Min),tostring(v.Max)) end,
NumberSequence = function() return "NumberSequence.new(...)" end,
ColorSequence = function() return "ColorSequence.new(...)" end,
EnumItem = tostring,
}
local function ser(v, depth, seen, maxd, code)
depth = depth or 0
seen = seen or {}
maxd = maxd or 6
local t = typeof(v)
if t == "nil" or t == "boolean" then return tostring(v) end
if t == "number" then
if v ~= v then return "0/0" end
if v == math.huge then return "math.huge" end
if v == -math.huge then return "-math.huge" end
if v % 1==0 and math.abs(v) < 1e15 then return tostring(v) end
return ("%.6f"):format(v)
end
if t == "string" then return ("%q"):format(v) end
if t == "Vector3" then
return ("Vector3.new(%.4f, %.4f, %.4f)"):format(v.X,v.Y, v.Z)
elseif t == "Vector2" then
return ("Vector2.new(%.4f, %.4f)"):format(v.X, v.Y)
elseif t == "CFrame" then
local c = {v:GetComponents()}
for i = 1, #c do c[i] = ("%.5f"):format(c[i]) end
return "CFrame.new(" .. table.concat(c, ", ") .. ")"
elseif t == "Color3" then
return ("Color3.fromRGB(%d, %d, %d)"):format(math.floor(v.R*255+0.5),math.floor(v.G*255+0.5), math.floor(v.B*255+0.5))
elseif t == "UDim2" then
return ("UDim2.new(%.4f, %d, %.4f, %d)"):format(v.X.Scale, v.X.Offset, v.Y.Scale, v.Y.Offset)
elseif OTHER[t] then
return OTHER[t](v)
end
if t=="Instance" then
if code then return pathExpr(v) end
local ok, name = pcall(function() return v:GetFullName() end)
if ok then return name end
return "[" .. v.ClassName .. "]"
end
if t == "RBXScriptSignal" then
return code and "nil --[[RBXScriptSignal]]" or "RBXScriptSignal"
end
if t == "function" then
if code then return "nil --[[function]]" end
local ok, src = pcall(debug.info, v, "s")
return "function" .. (ok and (" --[[" .. tostring(src) .. "]]") or "")
end
if t == "thread" then
return code and "nil --[[thread]]" or "coroutine"
end
if t ~= "table" then return tostring(v) end
if seen[v] then return code and "nil --[[cycle]]" or "--[[cycle]]" end
if depth >= maxd then return code and "nil --[[max depth]]" or "--[[max depth]]" end
seen[v]=true
local parts = {}
local n = #v
local shown = math.min(n, 200)
for i = 1, shown do
table.insert(parts, ser(v[i], depth + 1,seen, maxd, code))
end
if n > shown then
table.insert(parts, "--[[+" .. (n - shown) .. " more]]")
end
local extra = 0
for k, val in pairs(v) do
if not (type(k) == "number" and k>=1 and k <= n) then
extra = extra + 1
if extra > 60 then
parts[#parts+1] = "--[[...]]"
break
end
local key
if type(k) == "string" and k:match("^[%a_][%w_]*$") then
key=k
else
key = "[" .. ser(k, depth+1, seen, maxd, code) .. "]"
end
parts[#parts+1] = key .. " = " .. ser(val, depth + 1, seen, maxd, code)
end
end
seen[v] = nil
return "{" .. table.concat(parts, ", ") .. "}"
end
local function fullPath(r)
local ok,p = pcall(function() return r:GetFullName() end)
if ok then return p end
return "[" .. tostring(r) .. "]"
end
local function shortPath(full)
if not full then return "?" end
local bits = {}
for b in full:gmatch("[^%.]+") do bits[#bits+1] = b end
if #bits <= 2 then return full end
return bits[#bits-1] .. "." .. bits[#bits]
end
local function preview(args, n)
if not args then return "()" end
n=n or args.n or #args
if n == 0 then return "()" end
local out = {}
for i = 1, math.min(n, 3) do
local s = ser(args[i], 0, {}, 2)
if #s > 42 then s = s:sub(1, 39) .. "..." end
out[#out+1]=s
end
if n > 3 then out[#out+1] = "..." end
return "(" .. table.concat(out, ", ") .. ")"
end
local queue = {}
local function push(dir, remote, method, args)
if not S.on or S.paused or S.ignored[remote] then return end
if #queue >= S.maxQueue then return end
queue[#queue+1] = {
dir = dir, remote = remote, method = method, args = args,
n = args and args.n or 0,
stamp=os.date("%H:%M:%S"),
blocked = S.blocked[remote] == true,
}
end
local function trimLog()
local extra = #S.log - S.cap
if extra > 0 then
S.log = table.move(S.log, extra + 1, #S.log,1,{})
end
end
local EVENTS = {RemoteEvent = true, UnreliableRemoteEvent = true}
local REMOTES = {RemoteEvent = true, UnreliableRemoteEvent = true, RemoteFunction = true}
local function classOf(r)
local ok, c = pcall(function() return r.ClassName end)
if ok then return c end
end
local function isEvent(r) return EVENTS[classOf(r)] == true end
local function isFunc(r) return classOf(r) == "RemoteFunction" end
local old_namecall,old_newindex,hookedMt
local function wrapInvoke(remote, orig)
local w=function(...)
local args = table.pack(...)
pcall(push, "in", remote, "OnClientInvoke",args)
return orig(unpack(args, 1, args.n))
end
S.wrapped[w]=true
return w
end
local function installHooks()
if not can.hooks then
return false, "executor is missing getrawmetatable / getnamecallmethod"
end
local mt = getrawmetatable(game)
hookedMt = mt
old_namecall = mt.__namecall
old_newindex = mt.__newindex
if can.readonly then pcall(setreadonly, mt,false) end
local function nc(self, ...)
local method = getnamecallmethod()
if (method == "FireServer" or method == "InvokeServer")
and typeof(self) == "Instance"
and not S.muted[coroutine.running()]
and REMOTES[self.ClassName] then
local blocked=S.blocked[self]
if blocked or (S.on and not S.paused and not S.ignored[self]) then
pcall(push, "out",self, method, table.pack(...))
if can.setnc then setnamecallmethod(method) end
if blocked then return nil end
end
end
return old_namecall(self, ...)
end
local function ni(self, key, value)
if key == "OnClientInvoke" and type(value) == "function"
and not S.wrapped[value]
and typeof(self) == "Instance" and self.ClassName == "RemoteFunction" then
return old_newindex(self, key,wrapInvoke(self, value))
end
return old_newindex(self, key, value)
end
local wrap = (can.cclosure and newcclosure) or function(f) return f end
local ok, err = pcall(function()
mt.__namecall = wrap(nc)
mt.__newindex = wrap(ni)
end)
if not ok then
pcall(function()
mt.__namecall = old_namecall
mt.__newindex = old_newindex
end)
end
if can.readonly then pcall(setreadonly, mt, true) end
if not ok then
hookedMt = nil
return false, "couldn't write metatable: " .. tostring(err)
end
return true
end
local function removeHooks()
if not hookedMt then return end
if can.readonly then pcall(setreadonly, hookedMt, false) end
if old_namecall then pcall(function() hookedMt.__namecall = old_namecall end) end
if old_newindex then pcall(function() hookedMt.__newindex=old_newindex end) end
if can.readonly then pcall(setreadonly, hookedMt, true) end
hookedMt = nil
end
local function wrapExisting(remote)
if not (S.hooked and can.cbvalue) then return end
local ok, cb=pcall(getcallbackvalue, remote, "OnClientInvoke")
if ok and type(cb) == "function" and not S.wrapped[cb] then
pcall(function() remote.OnClientInvoke = cb end)
end
end
local function track(inst)
if S.dead then return end
local c=inst.ClassName
if EVENTS[c] then
if S.listeners[inst] then return end
S.listeners[inst]=inst.OnClientEvent:Connect(function(...)
push("in",inst, "OnClientEvent",table.pack(...))
end)
S.nListen += 1
elseif c == "RemoteFunction" then
wrapExisting(inst)
end
end
local function startTracking()
table.insert(S.conns, game.DescendantAdded:Connect(function(inst)
pcall(track, inst)
end))
task.spawn(function()
local ok, all = pcall(game.GetDescendants, game)
if not ok then return end
for i, inst in ipairs(all) do
if S.dead then return end
pcall(track, inst)
if i%2500 == 0 then task.wait() end
end
end)
end
local function disconnectAll()
for _, c in ipairs(S.conns) do pcall(c.Disconnect, c) end
S.conns = {}
for _,c in pairs(S.listeners) do pcall(c.Disconnect, c) end
S.listeners=weak()
S.nListen = 0
end
local function copy(text)
text = tostring(text)
local tries = {setclipboard, toclipboard, writeclipboard, syn and syn.write_clipboard}
for i = 1, 4 do
local f = tries[i]
if isfn(f) and pcall(f, text) then return true end
end
return false
end
local function saveFile(name, body)
if not can.writefile then return false, "writefile unavailable" end
if can.folders then
pcall(function() if not isfolder("LexSpy") then makefolder("LexSpy") end end)
end
local path="LexSpy/" .. name
local ok = pcall(writefile, path, body)
if ok then return true, path end
return false, "writefile failed"
end
local function quiet(fn)
local co = coroutine.running()
S.muted[co] = true
local res = table.pack(pcall(fn))
S.muted[co] = nil
return res
end
local function flash(btn,msg, back)
if not btn then return end
btn.Text = msg
task.delay(1.2, function() btn.Text = back end)
end
local function argList(e)
local out = {}
for i = 1, e.n do out[i] = ser(e.args[i], 0, {}, 10,true) end
return table.concat(out, ", ")
end
local function callText(e)
local path, m = pathExpr(e.remote), e.method
local params = e.n > 0 and "..." or ""
if m == "OnClientEvent" then
return ("%s.OnClientEvent:Connect(function(%s)\n -- captured %s\nend)"):format(path, params, e.stamp)
end
if m == "OnClientInvoke" then
return ("%s.OnClientInvoke = function(%s)\n -- captured %s\nend"):format(path, params,e.stamp)
end
return ("%s:%s(%s)"):format(path, m, argList(e))
end
local function editText(e)
if e.dir == "in" and e.method == "OnClientEvent" and can.fire then
local a = argList(e)
return ("firesignal(%s.OnClientEvent%s)"):format(pathExpr(e.remote), a ~= "" and (", " .. a) or "")
end
return callText(e)
end
local function detailText(e)
local path = fullPath(e.remote)
local L = {
"Remote : " .. path,
"Class : " .. e.remote.ClassName,
"Method : " .. e.method,
"Direction: " .. (e.dir == "in" and "INCOMING (server → client)" or "OUTGOING (client → server)"),
"Time : " .. e.stamp,
}
local nice = friendly(path)
if nice then table.insert(L, "Friendly : " .. nice) end
if e.blocked then table.insert(L,"Status : BLOCKED") end
table.insert(L,"")
table.insert(L, ("Arguments (%d):"):format(e.n))
if e.n == 0 then
table.insert(L, " (none)")
else
for i = 1, e.n do
table.insert(L, (" [%d] (%s)"):format(i, typeof(e.args[i])))
table.insert(L, " " .. ser(e.args[i]))
end
end
table.insert(L, "")
table.insert(L, "Generated:")
table.insert(L,callText(e))
return table.concat(L, "\n")
end
local renderDetail, genScript
local function selected()
if not S.sel then return end
for _, e in ipairs(S.log) do
if e.id == S.sel then return e end
end
end
local UI = {}
local C = {
bg = Color3.fromRGB(18, 18, 22),
bgAlt = Color3.fromRGB(24, 24, 30),
panel = Color3.fromRGB(28, 28, 35),
row = Color3.fromRGB(32, 32, 40),
rowSel = Color3.fromRGB(48, 70,110),
accent = Color3.fromRGB(90, 150, 255),
incoming = Color3.fromRGB(80, 220, 140),
outgoing = Color3.fromRGB(255, 170,60),
text = Color3.fromRGB(230, 230, 235),
dim = Color3.fromRGB(150, 150, 160),
danger=Color3.fromRGB(255, 80, 80),
gold = Color3.fromRGB(255,200,60),
}
local function new(class, props, parent)
local o = Instance.new(class)
for k, v in pairs(props or {}) do o[k] = v end
if parent then o.Parent = parent end
return o
end
local function corner(p, r)
return new("UICorner", {CornerRadius = UDim.new(0, r or 6)}, p)
end
local function stroke(p, color, thick, trans)
return new("UIStroke", {
Color = color or C.accent,
Thickness = thick or 1,
Transparency = trans or 0.5,
ApplyStrokeMode = Enum.ApplyStrokeMode.Border,
}, p)
end
local function btn(parent, text, color, size, pos)
local b = new("TextButton", {
Text = text, Font=Enum.Font.GothamBold, TextSize = 12, TextColor3 = C.text,
BackgroundColor3 = color or C.panel, BackgroundTransparency=0.15,
BorderSizePixel = 0, TextTruncate = Enum.TextTruncate.AtEnd,
Size=size, Position = pos,
}, parent)
corner(b, 5)
stroke(b, C.accent, 1,0.7)
return b
end
local W, H = 820, 540
local TB_H = 68
local EDIT_H, GRID_H=62, 86
local function attach(gui, opener)
local targets={}
if typeof(CoreGui) == "Instance" then table.insert(targets, CoreGui) end
if can.hui then
local ok, h = pcall(gethui)
if ok and typeof(h) == "Instance" then table.insert(targets, h) end
end
local pg = plr and (plr:FindFirstChild("PlayerGui") or plr:WaitForChild("PlayerGui",5))
if pg then table.insert(targets, pg) end
for _, t in ipairs(targets) do
for _, n in ipairs({"LexRemoteSpy", "LexRemoteSpyOpener"}) do
local old = t:FindFirstChild(n)
if old then pcall(old.Destroy, old) end
end
end
for _, t in ipairs(targets) do
pcall(function() gui.Parent = t end)
if gui.Parent == t then
pcall(function() opener.Parent = t end)
return true
end
end
return false
end
local function refreshStatus()
if not UI.status then return end
local txt,col
if not S.on then
txt, col = "OFF", C.danger
elseif S.paused then
txt,col = "PAUSED", C.outgoing
else
txt, col = "ACTIVE", C.incoming
end
UI.status.Text = txt
UI.status.TextColor3 = col
UI.dot.BackgroundColor3 = col
end
local function resetDetail()
S.sel=nil
UI.detailBox.Text = ""
UI.detailTitle.Text = "Select an entry"
UI.editBox.Text = ""
UI.editId = nil
end
local function buildUI()
local gui = new("ScreenGui", {
Name = "LexRemoteSpy", ResetOnSpawn = false, DisplayOrder=999,
ZIndexBehavior = Enum.ZIndexBehavior.Sibling,
})
local opener = new("ScreenGui",{
Name = "LexRemoteSpyOpener", ResetOnSpawn = false, DisplayOrder = 999,
ZIndexBehavior = Enum.ZIndexBehavior.Sibling, Enabled = false,
})
UI.gui = gui
UI.opener=opener
local tab = new("TextButton", {
Text = "LEX", Font = Enum.Font.GothamBlack, TextSize = 12, TextColor3 = C.text,
BackgroundColor3 = C.bgAlt, BorderSizePixel = 0,
Size = UDim2.fromOffset(44, 28), Position = UDim2.new(0, 8, 0.5, -14),
}, opener)
corner(tab, 6)
stroke(tab, C.accent, 1, 0.4)
UI.setOpen = function(v)
gui.Enabled = v
opener.Enabled = not v
end
tab.MouseButton1Click:Connect(function() UI.setOpen(true) end)
local main = new("Frame", {
Name="Main", Size = UDim2.fromOffset(W,H),
Position = UDim2.new(0.5,-W/2, 0.5,-H/2),
BackgroundColor3 = C.bg, BorderSizePixel = 0, Active=true, Draggable = true,
}, gui)
corner(main, 10)
stroke(main, C.accent, 1, 0.4)
local hdr = new("Frame",{
Size = UDim2.new(1, 0, 0, 40), BackgroundColor3 = C.bgAlt, BorderSizePixel = 0,
}, main)
corner(hdr, 10)
new("TextLabel", {
Text = " REMOTE SPY", Font = Enum.Font.GothamBlack,TextSize = 16,TextColor3 = C.text,
BackgroundTransparency = 1, TextXAlignment = Enum.TextXAlignment.Left,
Size=UDim2.new(0, 160, 1, 0), Position = UDim2.new(0, 8,0, 0),
}, hdr)
UI.dot = new("Frame", {
Size = UDim2.fromOffset(10, 10),Position = UDim2.new(0, 172, 0.5, -5),
BackgroundColor3 = C.incoming, BorderSizePixel=0,
}, hdr)
corner(UI.dot, 5)
UI.status = new("TextLabel", {
Text = "ACTIVE",Font = Enum.Font.GothamBold, TextSize = 12,TextColor3 = C.incoming,
BackgroundTransparency = 1, TextXAlignment = Enum.TextXAlignment.Left,
Size = UDim2.new(0, 100, 1, 0), Position = UDim2.new(0, 188, 0, 0),
}, hdr)
local mode = isBB and "BB MODE" or "UNIVERSAL MODE"
if not S.hooked then mode = mode .. " (IN ONLY)" end
new("TextLabel", {
Text = mode, Font = Enum.Font.GothamBold,TextSize = 11,
TextColor3 = isBB and C.gold or C.dim,BackgroundTransparency = 1,
Size = UDim2.new(0, 240, 1, 0), Position=UDim2.new(0.5,-120, 0, 0),
TextXAlignment = Enum.TextXAlignment.Center,
}, hdr)
local closeBtn = new("TextButton", {
Text = "✕", Font = Enum.Font.GothamBold, TextSize = 16, TextColor3 = C.danger,
BackgroundTransparency = 1, Size = UDim2.fromOffset(40, 40), Position = UDim2.new(1,-40, 0, 0),
}, hdr)
local minBtn = new("TextButton",{
Text = "—", Font = Enum.Font.GothamBold, TextSize = 16, TextColor3 = C.dim,
BackgroundTransparency = 1,Size = UDim2.fromOffset(40, 40), Position = UDim2.new(1, -80,0, 0),
}, hdr)
local unloadBtn = new("TextButton", {
Text = "Unload", Font = Enum.Font.GothamBold,TextSize = 11, TextColor3 = C.dim,
BackgroundTransparency = 1, Size = UDim2.fromOffset(60,40), Position = UDim2.new(1, -150, 0, 0),
}, hdr)
local tb = new("Frame", {
Name = "Toolbar",Size = UDim2.new(1, 0, 0, TB_H), Position = UDim2.new(0, 0, 0, 40),
BackgroundColor3 = C.bgAlt, BorderSizePixel = 0,
},main)
local search = new("TextBox", {
Size = UDim2.new(0, 200, 0, 26), Position = UDim2.new(0, 8,0, 6),
BackgroundColor3 = C.panel, BorderSizePixel = 0, Text = "",
PlaceholderText = "Search remote name...", PlaceholderColor3 = C.dim,
Font = Enum.Font.Gotham, TextSize = 12, TextColor3 = C.text,
TextXAlignment = Enum.TextXAlignment.Left, ClearTextOnFocus = false,
},tb)
corner(search, 5)
stroke(search, C.accent, 1, 0.7)
search:GetPropertyChangedSignal("Text"):Connect(function()
S.query=search.Text
S.dirty = true
end)
UI.dirBtn = btn(tb, "All", C.panel, UDim2.fromOffset(80, 26), UDim2.new(0, 216, 0, 6))
UI.bbBtn = btn(tb, "BB Only", C.panel, UDim2.fromOffset(80, 26), UDim2.new(0, 302, 0, 6))
UI.pauseBtn = btn(tb, "Pause", C.panel, UDim2.fromOffset(70, 26), UDim2.new(0,388, 0, 6))
UI.scrollBtn = btn(tb, "AutoScroll ✓", C.rowSel,UDim2.fromOffset(90, 26), UDim2.new(0,464, 0,6))
if not S.autoscroll then
UI.scrollBtn.Text = "AutoScroll"
UI.scrollBtn.BackgroundColor3=C.panel
end
local exportBtn = btn(tb, "Export",C.panel, UDim2.fromOffset(70, 26), UDim2.new(1,-258, 0, 6))
local copyAllBtn = btn(tb, "Copy All", C.panel, UDim2.fromOffset(80,26), UDim2.new(1, -178,0,6))
local clearBtn = btn(tb, "Clear",C.panel, UDim2.fromOffset(70, 26), UDim2.new(1, -90, 0, 6))
local unignoreBtn = btn(tb, "Unignore All", C.panel, UDim2.fromOffset(100, 26), UDim2.new(0, 8, 0, 36))
local unblockBtn = btn(tb, "Unblock All", C.panel, UDim2.fromOffset(100, 26), UDim2.new(0, 114, 0, 36))
local capBtn = btn(tb,"Max: " .. S.cap, C.panel, UDim2.fromOffset(86, 26),UDim2.new(0, 220, 0, 36))
local body = new("Frame", {
Name = "Content", Size = UDim2.new(1, 0, 1, -40 - TB_H - 24),
Position = UDim2.new(0, 0, 0, 40 + TB_H), BackgroundColor3 = C.bg, BorderSizePixel = 0,
}, main)
local listBox=new("Frame", {
Size = UDim2.new(0.58, -8, 1, -8), Position = UDim2.new(0, 6, 0, 4),
BackgroundColor3 = C.bgAlt, BorderSizePixel = 0,
}, body)
corner(listBox, 8)
UI.list = new("ScrollingFrame", {
Size = UDim2.new(1, -8, 1, -8), Position = UDim2.new(0, 4, 0, 4),
BackgroundTransparency=1, BorderSizePixel = 0, ScrollBarThickness=6,
ScrollBarImageColor3 = C.accent, CanvasSize = UDim2.new(),
AutomaticCanvasSize = Enum.AutomaticSize.Y,
}, listBox)
new("UIListLayout", {Padding = UDim.new(0, 3),SortOrder = Enum.SortOrder.LayoutOrder}, UI.list)
new("UIPadding", {PaddingTop = UDim.new(0, 2), PaddingLeft = UDim.new(0, 2), PaddingRight = UDim.new(0, 2)}, UI.list)
local right = new("Frame", {
Size = UDim2.new(0.42, -8, 1,-8), Position = UDim2.new(0.58, 2, 0, 4),
BackgroundColor3 = C.bgAlt, BorderSizePixel = 0,
},body)
corner(right, 8)
UI.detailTitle=new("TextLabel", {
Text = "Select an entry", Font = Enum.Font.GothamBold, TextSize = 13, TextColor3 = C.text,
BackgroundTransparency = 1, TextXAlignment = Enum.TextXAlignment.Left,
Size = UDim2.new(1, -12,0, 26), Position = UDim2.new(0, 6, 0, 4),
}, right)
local scroll = new("ScrollingFrame", {
Size = UDim2.new(1, -12, 1, -(30 + 4+EDIT_H+4 + GRID_H + 4)),
Position = UDim2.new(0, 6, 0, 30), BackgroundColor3 = C.panel, BorderSizePixel = 0,
ScrollBarThickness = 6,ScrollBarImageColor3 = C.accent, CanvasSize = UDim2.new(),
AutomaticCanvasSize = Enum.AutomaticSize.Y,
},right)
corner(scroll, 6)
UI.detailBox=new("TextBox", {
Size = UDim2.new(1, -8, 0, 0), Position = UDim2.new(0, 4, 0, 4), BackgroundTransparency = 1,
Text="",Font = Enum.Font.Code, TextSize = 12, TextColor3 = C.text, TextWrapped = true,
TextXAlignment = Enum.TextXAlignment.Left, TextYAlignment = Enum.TextYAlignment.Top,
TextEditable = false, ClearTextOnFocus = false, AutomaticSize = Enum.AutomaticSize.Y,
}, scroll)
UI.editBox = new("TextBox", {
Name = "Editor", Size=UDim2.new(1, -12, 0, EDIT_H),
Position = UDim2.new(0, 6, 1, -(GRID_H + 8 + EDIT_H)),
BackgroundColor3 = C.panel, BorderSizePixel = 0,Text = "",
PlaceholderText = "Select an entry to load its call here, edit it, then press Run Edited",
PlaceholderColor3 = C.dim, Font = Enum.Font.Code, TextSize = 11, TextColor3 = C.text,
TextWrapped = true, MultiLine = true, ClearTextOnFocus = false, ClipsDescendants = true,
TextXAlignment = Enum.TextXAlignment.Left, TextYAlignment = Enum.TextYAlignment.Top,
}, right)
corner(UI.editBox,6)
stroke(UI.editBox, C.accent, 1,0.7)
local grid = new("Frame", {
Size = UDim2.new(1, -12, 0, GRID_H), Position = UDim2.new(0, 6, 1, -(GRID_H + 4)),
BackgroundTransparency = 1,
}, right)
new("UIGridLayout", {
CellSize = UDim2.new(1/3, -4,0, 26), CellPadding = UDim2.new(0, 6, 0, 4),
SortOrder = Enum.SortOrder.LayoutOrder,
}, grid)
UI.copyCall = btn(grid, "Copy Call")
UI.copyArgs = btn(grid, "Copy Args")
UI.copyPath = btn(grid, "Copy Path")
UI.fireBtn = btn(grid, "Fire Again")
UI.invokeBtn = btn(grid, "Invoke Again")
UI.runBtn = btn(grid, "Run Edited")
UI.blockBtn = btn(grid, "Block")
UI.ignoreBtn = btn(grid, "Ignore")
UI.onlyBtn = btn(grid, "Only This")
UI.removeBtn = btn(grid, "Remove", C.danger)
UI.fireLabel = "Fire Again"
UI.invokeBtn.Visible = false
local footer=new("Frame", {
Name = "Footer", Size = UDim2.new(1, 0, 0, 24), Position = UDim2.new(0, 0, 1, -24),
BackgroundColor3 = C.bgAlt, BorderSizePixel = 0,
}, main)
UI.stats = new("TextLabel", {
Text = "0 total | 0 in | 0 out | 0 blocked",Font=Enum.Font.Gotham,TextSize = 11,
TextColor3 = C.dim, BackgroundTransparency = 1, TextXAlignment = Enum.TextXAlignment.Left,
Size = UDim2.new(1, -16, 1, 0), Position = UDim2.new(0, 8, 0, 0),
}, footer)
closeBtn.MouseButton1Click:Connect(function() UI.setOpen(false) end)
local armed = false
unloadBtn.MouseButton1Click:Connect(function()
if not armed then
armed = true
unloadBtn.Text = "Sure?"
unloadBtn.TextColor3=C.danger
task.delay(2, function()
armed = false
unloadBtn.Text = "Unload"
unloadBtn.TextColor3 = C.dim
end)
return
end
if env.__LEXSPY_CLEANUP then env.__LEXSPY_CLEANUP() end
end)
minBtn.MouseButton1Click:Connect(function()
local open = main.Size.Y.Offset ~= 40
TS:Create(main, TweenInfo.new(0.18), {Size = UDim2.fromOffset(W, open and 40 or H)}):Play()
body.Visible = not open
footer.Visible = not open
tb.Visible = not open
end)
UI.dirBtn.MouseButton1Click:Connect(function()
local order = {"All","Incoming", "Outgoing"}
local at = table.find(order, S.dir) or 1
S.dir=order[at % #order+1]
UI.dirBtn.Text = S.dir
S.dirty = true
end)
UI.bbBtn.MouseButton1Click:Connect(function()
S.bbOnly = not S.bbOnly
UI.bbBtn.Text = S.bbOnly and "BB Only ✓" or "BB Only"
UI.bbBtn.BackgroundColor3 = S.bbOnly and C.rowSel or C.panel
S.dirty = true
end)
UI.pauseBtn.MouseButton1Click:Connect(function()
S.paused = not S.paused
UI.pauseBtn.Text = S.paused and "Resume" or "Pause"
UI.pauseBtn.BackgroundColor3 = S.paused and C.rowSel or C.panel
refreshStatus()
end)
UI.scrollBtn.MouseButton1Click:Connect(function()
S.autoscroll = not S.autoscroll
UI.scrollBtn.Text = S.autoscroll and "AutoScroll ✓" or "AutoScroll"
UI.scrollBtn.BackgroundColor3 = S.autoscroll and C.rowSel or C.panel
end)
clearBtn.MouseButton1Click:Connect(function()
S.log = {}
queue = {}
S.dirty = true
resetDetail()
end)
exportBtn.MouseButton1Click:Connect(function()
local fname = "remote_log_" .. os.date("%Y%m%d_%H%M%S") .. ".lua"
local ok, where = saveFile(fname, genScript(S.log))
if ok then print(TAG .. "saved " .. tostring(where)) end
flash(exportBtn, ok and "Saved ✓" or "No writefile", "Export")
end)
unignoreBtn.MouseButton1Click:Connect(function()
S.ignored = {}
S.dirty = true
renderDetail()
flash(unignoreBtn, "Done ✓", "Unignore All")
end)
unblockBtn.MouseButton1Click:Connect(function()
S.blocked = {}
S.dirty = true
renderDetail()
flash(unblockBtn, "Done ✓", "Unblock All")
end)
capBtn.MouseButton1Click:Connect(function()
local sizes={200, 600, 1500, 3000}
local at = table.find(sizes, S.cap) or 0
S.cap = sizes[at%#sizes + 1]
capBtn.Text = "Max: " .. S.cap
trimLog()
S.dirty = true
end)
copyAllBtn.MouseButton1Click:Connect(function()
flash(copyAllBtn, copy(genScript(S.log)) and "Copied ✓" or "No clipboard", "Copy All")
end)
UI.copyCall.MouseButton1Click:Connect(function()
local e = selected()
if not e then return end
flash(UI.copyCall, copy(callText(e)) and "Copied ✓" or "No clipboard", "Copy Call")
end)
UI.copyArgs.MouseButton1Click:Connect(function()
local e = selected()
if not e then return end
local parts = {}
for i = 1, e.n do parts[i] = ser(e.args[i], 0, {}, 10, true) end
flash(UI.copyArgs, copy(table.concat(parts, ",\n")) and "Copied ✓" or "No clipboard", "Copy Args")
end)
UI.copyPath.MouseButton1Click:Connect(function()
local e = selected()
if not e then return end
flash(UI.copyPath, copy(fullPath(e.remote)) and "Copied ✓" or "No clipboard", "Copy Path")
end)
UI.fireBtn.MouseButton1Click:Connect(function()
local e = selected()
if not e or not isEvent(e.remote) then return end
local res
if e.dir=="in" then
if not can.fire then return end
res = quiet(function() firesignal(e.remote.OnClientEvent, unpack(e.args, 1, e.n)) end)
else
res = quiet(function() e.remote:FireServer(unpack(e.args, 1, e.n)) end)
end
flash(UI.fireBtn,res[1] and "Fired ✓" or "Error", UI.fireLabel)
end)
UI.invokeBtn.MouseButton1Click:Connect(function()
local e = selected()
if not e or e.dir ~= "out" or not isFunc(e.remote) then return end
local res = quiet(function() return e.remote:InvokeServer(unpack(e.args, 1, e.n)) end)
if S.sel==e.id then
if res[1] then
local out = {}
for i = 2, res.n do table.insert(out, ser(res[i])) end
UI.detailBox.Text = UI.detailBox.Text .. "\n\n-- InvokeServer returned:\n" .. (#out > 0 and table.concat(out, ",\n") or "(nothing)")
else
UI.detailBox.Text = UI.detailBox.Text .. "\n\n-- InvokeServer error:\n" .. tostring(res[2])
end
end
flash(UI.invokeBtn, res[1] and "Invoked ✓" or "Error", "Invoke Again")
end)
UI.runBtn.MouseButton1Click:Connect(function()
local src = UI.editBox.Text
if not src:find("%S") then return end
if not can.loadstr then
flash(UI.runBtn, "No loadstring", "Run Edited")
return
end
local id = S.sel
local fn, cerr = loadstring(src)
if not fn then
if S.sel == id then
UI.detailBox.Text = UI.detailBox.Text .. "\n\n-- Run Edited: syntax error\n" .. tostring(cerr)
end
flash(UI.runBtn, "Syntax error", "Run Edited")
return
end
local res = quiet(fn)
if S.sel == id then
if res[1] then
local out = {}
for i = 2, res.n do out[#out+1] = ser(res[i]) end
UI.detailBox.Text = UI.detailBox.Text .. "\n\n-- Run Edited: ok" .. (#out > 0 and ("\n" .. table.concat(out, ",\n")) or "")
else
UI.detailBox.Text = UI.detailBox.Text .. "\n\n-- Run Edited: error\n" .. tostring(res[2])
end
end
flash(UI.runBtn,res[1] and "Ran ✓" or "Error", "Run Edited")
end)
UI.blockBtn.MouseButton1Click:Connect(function()
local e = selected()
if not e then return end
if S.blocked[e.remote] then
S.blocked[e.remote] = nil
else
S.blocked[e.remote]=true
end
S.dirty = true
renderDetail()
end)
UI.ignoreBtn.MouseButton1Click:Connect(function()
local e = selected()
if not e then return end
S.ignored[e.remote] = not S.ignored[e.remote] or nil
S.dirty = true
renderDetail()
end)
UI.onlyBtn.MouseButton1Click:Connect(function()
local e = selected()
if not e then return end
local nm=""
pcall(function() nm=e.remote.Name end)
search.Text = nm
end)
UI.removeBtn.MouseButton1Click:Connect(function()
local e = selected()
if not e then return end
for i, v in ipairs(S.log) do
if v.id == e.id then
table.remove(S.log, i)
break
end
end
S.dirty = true
resetDetail()
end)
table.insert(S.conns,UIS.InputBegan:Connect(function(input, gp)
if gp then return end
if input.KeyCode==Enum.KeyCode.RightControl then
UI.setOpen(not gui.Enabled)
end
end))
if not attach(gui, opener) then
pcall(gui.Destroy, gui)
pcall(opener.Destroy, opener)
UI.gui = nil
UI.opener = nil
error("no usable GUI parent (CoreGui / gethui / PlayerGui all refused)")
end
end
local function passes(e)
if S.dir == "Incoming" and e.dir ~= "in" then return false end
if S.dir == "Outgoing" and e.dir ~= "out" then return false end
if S.bbOnly and not fullPath(e.remote):find("ReplicatedStorage.Remotes", 1, true) then
return false
end
if S.query ~= "" then
local q = S.query:lower()
if not (fullPath(e.remote):lower():find(q, 1, true) or e.method:lower():find(q, 1, true)) then
return false
end
end
return true
end
local rows = {}
local function getRow(i)
if rows[i] then return rows[i] end
local row = new("TextButton", {
Size=UDim2.new(1, -4, 0, 26), BackgroundColor3 = C.row, BorderSizePixel = 0,
Text = "", AutoButtonColor = false,
},UI.list)
corner(row, 4)
local stripe = new("Frame",{
Size = UDim2.fromOffset(3, 18), Position=UDim2.new(0, 4,0.5, -9),
BackgroundColor3 = C.incoming, BorderSizePixel = 0,
}, row)
corner(stripe, 2)
local txt = new("TextLabel", {
Size = UDim2.new(1, -16, 1, 0), Position = UDim2.new(0, 12, 0, 0), BackgroundTransparency = 1,
Text = "", Font = Enum.Font.Gotham,TextSize = 11, TextColor3 = C.text,
TextXAlignment = Enum.TextXAlignment.Left, TextTruncate = Enum.TextTruncate.AtEnd,
}, row)
local item = {row = row, stripe=stripe, txt = txt}
row.MouseButton1Click:Connect(function()
if item.id then
S.sel = item.id
S.dirty=true
renderDetail()
end
end)
rows[i] = item
return item
end
local function rebuildList()
if not UI.list then return end
local shown = {}
for i=#S.log, 1,-1 do
if passes(S.log[i]) then shown[#shown+1] = S.log[i] end
end
local count = math.min(#shown, 250)
for i = 1, count do
local e = shown[i]
local item = getRow(i)
item.row.Visible = true
item.row.LayoutOrder = i
item.row.BackgroundColor3 = e.id == S.sel and C.rowSel or C.row
item.stripe.BackgroundColor3 = e.dir == "in" and C.incoming or C.outgoing
item.id = e.id
if not e.rowText then
local path = fullPath(e.remote)
e.nice = friendly(path) ~= nil
e.rowText = ("[%s] %s %s %s %s"):format(e.dir == "in" and "IN " or "OUT",e.stamp,shortPath(path), e.method, preview(e.args, e.n))
end
local text = e.rowText
if e.nice then text = "★ " .. text end
if e.blocked then text="[BLOCKED] " .. text end
item.txt.Text = text
end
for i = count + 1, #rows do rows[i].row.Visible = false end
if S.autoscroll then UI.list.CanvasPosition = Vector2.new(0, 0) end
local nIn,nOut, nBlocked = 0, 0, 0
for _,e in ipairs(S.log) do
if e.dir == "in" then nIn += 1 else nOut += 1 end
if S.blocked[e.remote] then nBlocked += 1 end
end
UI.stats.Text=("%d total | %d in | %d out | %d blocked | %d shown | out-hook: %s | listening: %d"):format(
#S.log, nIn, nOut, nBlocked, count,S.hooked and "on" or "OFF", S.nListen)
end
function renderDetail()
local e=selected()
if not e then
UI.detailTitle.Text = "Select an entry"
UI.detailBox.Text = ""
if UI.editBox then
UI.editBox.Text = ""
UI.editId = nil
end
return
end
local path = fullPath(e.remote)
UI.detailTitle.Text = (friendly(path) or shortPath(path)) .. " — " .. e.method
UI.detailBox.Text = detailText(e)
UI.blockBtn.Text = S.blocked[e.remote] and "Unblock" or "Block"
UI.ignoreBtn.Text = S.ignored[e.remote] and "Unignore" or "Ignore"
local out = e.dir == "out"
UI.fireLabel=out and "Fire Again" or "Fire Client"
UI.fireBtn.Text = UI.fireLabel
UI.fireBtn.Visible = isEvent(e.remote) and (out or can.fire)
UI.invokeBtn.Visible = out and isFunc(e.remote)
if UI.editId ~= e.id then
UI.editBox.Text = editText(e)
UI.editId = e.id
end
end
function genScript(list)
local L={"-- Generated by LEX Remote Spy", "-- " .. os.date("%Y-%m-%d %H:%M:%S"), ""}
for _, e in ipairs(list) do
if passes(e) then
table.insert(L,"-- [" .. e.stamp .. "] " .. e.method)
table.insert(L, callText(e))
table.insert(L, "")
end
end
return table.concat(L,"\n")
end
local lastDraw=0
local function drain()
if #queue == 0 then return end
local batch = queue
queue = {}
for _, raw in ipairs(batch) do
table.insert(S.log, {
id=S.nextId, dir = raw.dir, remote = raw.remote, method = raw.method,
args = raw.args, n = raw.n, stamp=raw.stamp,
blocked = S.blocked[raw.remote] == true,
})
S.nextId += 1
end
trimLog()
S.dirty = true
end
local beat = RunService.Heartbeat:Connect(function()
drain()
local now = os.clock()
if S.dirty and now - lastDraw > 0.12 then
lastDraw = now
S.dirty = false
pcall(rebuildList)
end
end)
env.LexSpy = {
Toggle = function(state)
S.on = state ~= false
refreshStatus()
end,
Clear = function()
S.log = {}
queue = {}
S.sel = nil
S.dirty=true
end,
GetLog = function()
local out = {}
for i, e in ipairs(S.log) do out[i]=e end
return out
end,
Block = function(r) S.blocked[r] = true end,
Unblock = function(r) S.blocked[r] = nil end,
Ignore = function(r) S.ignored[r] = true end,
Unignore = function(r) S.ignored[r]=nil end,
GenerateScript = function() return genScript(S.log) end,
SaveLog = function(name) return saveFile(name or "remote_log.lua",genScript(S.log)) end,
SetFilter = function(f) S.dir = f; S.dirty = true end,
SetBBOnly = function(v) S.bbOnly = v; S.dirty = true end,
Show = function(v) if UI.setOpen then UI.setOpen(v ~= false) end end,
Unload = function() if env.__LEXSPY_CLEANUP then env.__LEXSPY_CLEANUP() end end,
}
env.__LEXSPY_CLEANUP=function()
env.__LEXSPY_LOADED = false
S.on = false
S.dead=true
if beat then pcall(beat.Disconnect, beat) end
disconnectAll()
removeHooks()
if UI.gui then pcall(UI.gui.Destroy, UI.gui) end
if UI.opener then pcall(UI.opener.Destroy, UI.opener) end
queue = {}
rows = {}
S.log = {}
env.LexSpy = nil
print(TAG .. "unloaded")
end
do
local called, ok, err = pcall(installHooks)
if not called then
err = ok
ok = false
end
S.hooked = ok == true
if not S.hooked then
warn(TAG .. "hook install failed (incoming still works): " .. tostring(err))
end
local uiOk, uiErr = pcall(buildUI)
if not uiOk then warn(TAG .. "UI build failed: " .. tostring(uiErr)) end
local trOk, trErr = pcall(startTracking)
if not trOk then warn(TAG .. "remote tracking failed: " .. tostring(trErr)) end
task.defer(function()
S.dirty = true
pcall(rebuildList)
end)
print(("%sloaded in %.0fms | bb: %s | out-hook: %s"):format(TAG, (os.clock() - t0)*1000,tostring(isBB), tostring(S.hooked)))
end🔍 ADVANCED REMOTE SPY | FireServer & InvokeServer Capture
Take a deeper look into Roblox remote communication with Advanced Remote Spy, a powerful developer-focused tool designed to help you inspect and understand remote activity.
⚡ FEATURES
💻 BUILT FOR DEVELOPERS
Whether you're debugging a game in Roblox Studio, investigating your own remote implementations, or learning how client-server communication works, Advanced Remote Spy gives you a more organised way to explore remote activity.
Understand the calls. Inspect the arguments. Investigate the behaviour.
⚠️ Disclaimer: Use only in Roblox experiences you own or have permission to test. Capture capabilities depend on the execution environment and available access.
🛠️ TOOL INFORMATION
Tool: Advanced Remote Spy
Platform: Roblox
Category: Remote Inspection / Developer Utilities
Status: [WORKING]
No comments yet. Be the first to comment!
1--[[
2▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄ ▄▄▄
3███ ███▀▀▀▀▀ ████▄████
4███ ███▄▄ ▀█████▀
5███ ███ ▄███████▄
6████████ ▀███████ ███▀ ▀███
7
8
9+------------------------------------------------+
10| LEX REMOTE SPY TOOL :: |
11| MADE BY LEX |
12| VERSION: 0.1.1 |
13| Open Source |
14+--------------------------------------------+
15--]]
16
17local env = getgenv and getgenv() or _G
18if env.__LEXSPY_CLEANUP then pcall(env.__LEXSPY_CLEANUP) end
19env.__LEXSPY_LOADED = true
20local t0 = os.clock()
21
22local Players=game:GetService('Players')
23local RunService = game:GetService("RunService")
24local UIS = game:GetService("UserInputService")
25local RS=game:GetService("ReplicatedStorage")
26local CoreGui = game:GetService("CoreGui")
27local TS = game:GetService('TweenService')
28local plr = Players.LocalPlayer
29
30local TAG = "[Lex Remote Spy] "
31local unpack = table.unpack or unpack
32local function isfn(f) return type(f) == "function" end
33
34local can={
35 hooks = isfn(getrawmetatable) and isfn(getnamecallmethod),
36 setnc = isfn(setnamecallmethod),
37 readonly=isfn(setreadonly),
38 cclosure = isfn(newcclosure),
39 cbvalue=isfn(getcallbackvalue),
40 writefile=isfn(writefile),
41 folders = isfn(isfolder) and isfn(makefolder),
42 loadstr = isfn(loadstring),
43 fire=isfn(firesignal),
44 hui = isfn(gethui),
45}
46local function weak() return setmetatable({}, {__mode = "k"}) end
47local remFolder = RS:FindFirstChild("Remotes")
48local isBB = remFolder ~= nil and remFolder:FindFirstChild("ParryButtonPress") ~= nil
49local S={
50 on = true,
51 paused = false,
52 dir = "All",
53 query="",
54 bbOnly = false,
55 autoscroll = true,
56 cap=600,
57 log = {},
58 nextId = 1,
59 sel = nil,
60 blocked={},
61 ignored={},
62 dirty=true,
63 maxQueue = 5000,
64 muted=weak(),
65 listeners=weak(),
66 nListen = 0,
67 wrapped = weak(),
68 conns = {},
69 hooked=false,
70 dead = false,
71}
72
73local BB_NAMES = {
74 ParryButtonPress = "Parry Request",
75 AbilityButtonPress = "Ability Request",
76 ParrySuccess = "Parry Success (server → client)",
77 ParryFailed = "Parry Failed",
78 ActivateSuper="Activate Super",
79 DefensiveMove = "Defensive Move",
80 TeleportToStandardGame = "Teleport To Standard Game",
81 Emotes="Emotes Remote",
82}
83
84local function friendly(path)
85 if not path then return end
86 for key, label in pairs(BB_NAMES) do
87 if path:find(key, 1, true) then return label end
88 end
89end
90
91local function buildPath(inst)
92 local chain = {}
93 local p = inst
94 while p and p ~= game do
95 table.insert(chain, 1, p)
96 p = p.Parent
97 end
98
99 if p ~= game or #chain == 0 then return nil end
100
101 local out, from
102 if chain[2]==plr then
103 out='game:GetService("Players").LocalPlayer'
104 from = 3
105 else
106 local root=chain[1]
107 local svc = false
108 pcall(function() svc = game:GetService(root.ClassName) == root end)
109 if svc then
110 out = ("game:GetService(%q)"):format(root.ClassName)
111 else
112 out = ("game:WaitForChild(%q)"):format(root.Name)
113 end
114 from = 2
115 end
116 for i = from, #chain do
117 out = out .. (":WaitForChild(%q)"):format(chain[i].Name)
118 end
119 return out
120end
121
122local function pathExpr(inst)
123 local ok, res = pcall(buildPath, inst)
124 if ok and res then return res end
125 local cls, nm = "Instance", "?"
126 pcall(function() cls, nm = inst.ClassName, inst.Name end)
127 return "nil --[[" .. tostring(cls) .. " " .. (tostring(nm):gsub("%]%]", "] ]")) .. " (not in game)]]"
128end
129
130local OTHER = {
131 BrickColor = function(v) return ("BrickColor.new(%q)"):format(v.Name) end,
132 UDim = function(v) return ("UDim.new(%.4f, %d)"):format(v.Scale, v.Offset) end,
133 Rect = function(v) return ("Rect.new(%g, %g, %g, %g)"):format(v.Min.X, v.Min.Y, v.Max.X, v.Max.Y) end,
134 NumberRange = function(v) return ("NumberRange.new(%s, %s)"):format(tostring(v.Min),tostring(v.Max)) end,
135 NumberSequence = function() return "NumberSequence.new(...)" end,
136 ColorSequence = function() return "ColorSequence.new(...)" end,
137 EnumItem = tostring,
138}
139
140local function ser(v, depth, seen, maxd, code)
141 depth = depth or 0
142 seen = seen or {}
143 maxd = maxd or 6
144 local t = typeof(v)
145
146 if t == "nil" or t == "boolean" then return tostring(v) end
147 if t == "number" then
148 if v ~= v then return "0/0" end
149 if v == math.huge then return "math.huge" end
150 if v == -math.huge then return "-math.huge" end
151 if v % 1==0 and math.abs(v) < 1e15 then return tostring(v) end
152 return ("%.6f"):format(v)
153 end
154 if t == "string" then return ("%q"):format(v) end
155
156 if t == "Vector3" then
157 return ("Vector3.new(%.4f, %.4f, %.4f)"):format(v.X,v.Y, v.Z)
158 elseif t == "Vector2" then
159 return ("Vector2.new(%.4f, %.4f)"):format(v.X, v.Y)
160 elseif t == "CFrame" then
161 local c = {v:GetComponents()}
162 for i = 1, #c do c[i] = ("%.5f"):format(c[i]) end
163 return "CFrame.new(" .. table.concat(c, ", ") .. ")"
164 elseif t == "Color3" then
165 return ("Color3.fromRGB(%d, %d, %d)"):format(math.floor(v.R*255+0.5),math.floor(v.G*255+0.5), math.floor(v.B*255+0.5))
166 elseif t == "UDim2" then
167 return ("UDim2.new(%.4f, %d, %.4f, %d)"):format(v.X.Scale, v.X.Offset, v.Y.Scale, v.Y.Offset)
168 elseif OTHER[t] then
169 return OTHER[t](v)
170 end
171
172 if t=="Instance" then
173 if code then return pathExpr(v) end
174 local ok, name = pcall(function() return v:GetFullName() end)
175 if ok then return name end
176 return "[" .. v.ClassName .. "]"
177 end
178 if t == "RBXScriptSignal" then
179 return code and "nil --[[RBXScriptSignal]]" or "RBXScriptSignal"
180 end
181
182 if t == "function" then
183 if code then return "nil --[[function]]" end
184 local ok, src = pcall(debug.info, v, "s")
185 return "function" .. (ok and (" --[[" .. tostring(src) .. "]]") or "")
186 end
187 if t == "thread" then
188 return code and "nil --[[thread]]" or "coroutine"
189 end
190 if t ~= "table" then return tostring(v) end
191
192 if seen[v] then return code and "nil --[[cycle]]" or "--[[cycle]]" end
193 if depth >= maxd then return code and "nil --[[max depth]]" or "--[[max depth]]" end
194 seen[v]=true
195
196 local parts = {}
197 local n = #v
198 local shown = math.min(n, 200)
199 for i = 1, shown do
200 table.insert(parts, ser(v[i], depth + 1,seen, maxd, code))
201 end
202 if n > shown then
203 table.insert(parts, "--[[+" .. (n - shown) .. " more]]")
204 end
205
206 local extra = 0
207 for k, val in pairs(v) do
208 if not (type(k) == "number" and k>=1 and k <= n) then
209 extra = extra + 1
210 if extra > 60 then
211 parts[#parts+1] = "--[[...]]"
212 break
213 end
214 local key
215 if type(k) == "string" and k:match("^[%a_][%w_]*$") then
216 key=k
217 else
218 key = "[" .. ser(k, depth+1, seen, maxd, code) .. "]"
219 end
220 parts[#parts+1] = key .. " = " .. ser(val, depth + 1, seen, maxd, code)
221 end
222 end
223 seen[v] = nil
224 return "{" .. table.concat(parts, ", ") .. "}"
225end
226
227local function fullPath(r)
228 local ok,p = pcall(function() return r:GetFullName() end)
229 if ok then return p end
230 return "[" .. tostring(r) .. "]"
231end
232
233local function shortPath(full)
234 if not full then return "?" end
235 local bits = {}
236 for b in full:gmatch("[^%.]+") do bits[#bits+1] = b end
237 if #bits <= 2 then return full end
238 return bits[#bits-1] .. "." .. bits[#bits]
239end
240
241local function preview(args, n)
242 if not args then return "()" end
243 n=n or args.n or #args
244 if n == 0 then return "()" end
245 local out = {}
246 for i = 1, math.min(n, 3) do
247 local s = ser(args[i], 0, {}, 2)
248 if #s > 42 then s = s:sub(1, 39) .. "..." end
249 out[#out+1]=s
250 end
251 if n > 3 then out[#out+1] = "..." end
252 return "(" .. table.concat(out, ", ") .. ")"
253end
254
255local queue = {}
256local function push(dir, remote, method, args)
257 if not S.on or S.paused or S.ignored[remote] then return end
258 if #queue >= S.maxQueue then return end
259 queue[#queue+1] = {
260 dir = dir, remote = remote, method = method, args = args,
261 n = args and args.n or 0,
262 stamp=os.date("%H:%M:%S"),
263 blocked = S.blocked[remote] == true,
264 }
265end
266
267local function trimLog()
268 local extra = #S.log - S.cap
269 if extra > 0 then
270 S.log = table.move(S.log, extra + 1, #S.log,1,{})
271 end
272end
273
274local EVENTS = {RemoteEvent = true, UnreliableRemoteEvent = true}
275local REMOTES = {RemoteEvent = true, UnreliableRemoteEvent = true, RemoteFunction = true}
276
277local function classOf(r)
278 local ok, c = pcall(function() return r.ClassName end)
279 if ok then return c end
280end
281local function isEvent(r) return EVENTS[classOf(r)] == true end
282local function isFunc(r) return classOf(r) == "RemoteFunction" end
283
284local old_namecall,old_newindex,hookedMt
285
286local function wrapInvoke(remote, orig)
287 local w=function(...)
288 local args = table.pack(...)
289 pcall(push, "in", remote, "OnClientInvoke",args)
290 return orig(unpack(args, 1, args.n))
291 end
292 S.wrapped[w]=true
293 return w
294end
295
296local function installHooks()
297 if not can.hooks then
298 return false, "executor is missing getrawmetatable / getnamecallmethod"
299 end
300
301
302 local mt = getrawmetatable(game)
303 hookedMt = mt
304 old_namecall = mt.__namecall
305 old_newindex = mt.__newindex
306 if can.readonly then pcall(setreadonly, mt,false) end
307
308 local function nc(self, ...)
309 local method = getnamecallmethod()
310 if (method == "FireServer" or method == "InvokeServer")
311 and typeof(self) == "Instance"
312 and not S.muted[coroutine.running()]
313 and REMOTES[self.ClassName] then
314 local blocked=S.blocked[self]
315 if blocked or (S.on and not S.paused and not S.ignored[self]) then
316 pcall(push, "out",self, method, table.pack(...))
317 if can.setnc then setnamecallmethod(method) end
318 if blocked then return nil end
319 end
320 end
321 return old_namecall(self, ...)
322 end
323 local function ni(self, key, value)
324 if key == "OnClientInvoke" and type(value) == "function"
325 and not S.wrapped[value]
326 and typeof(self) == "Instance" and self.ClassName == "RemoteFunction" then
327 return old_newindex(self, key,wrapInvoke(self, value))
328 end
329 return old_newindex(self, key, value)
330 end
331
332 local wrap = (can.cclosure and newcclosure) or function(f) return f end
333 local ok, err = pcall(function()
334 mt.__namecall = wrap(nc)
335 mt.__newindex = wrap(ni)
336 end)
337 if not ok then
338 pcall(function()
339 mt.__namecall = old_namecall
340 mt.__newindex = old_newindex
341 end)
342 end
343 if can.readonly then pcall(setreadonly, mt, true) end
344
345 if not ok then
346 hookedMt = nil
347 return false, "couldn't write metatable: " .. tostring(err)
348 end
349 return true
350end
351
352local function removeHooks()
353 if not hookedMt then return end
354 if can.readonly then pcall(setreadonly, hookedMt, false) end
355 if old_namecall then pcall(function() hookedMt.__namecall = old_namecall end) end
356 if old_newindex then pcall(function() hookedMt.__newindex=old_newindex end) end
357 if can.readonly then pcall(setreadonly, hookedMt, true) end
358 hookedMt = nil
359end
360
361
362local function wrapExisting(remote)
363 if not (S.hooked and can.cbvalue) then return end
364 local ok, cb=pcall(getcallbackvalue, remote, "OnClientInvoke")
365 if ok and type(cb) == "function" and not S.wrapped[cb] then
366 pcall(function() remote.OnClientInvoke = cb end)
367 end
368end
369
370local function track(inst)
371 if S.dead then return end
372 local c=inst.ClassName
373 if EVENTS[c] then
374 if S.listeners[inst] then return end
375 S.listeners[inst]=inst.OnClientEvent:Connect(function(...)
376 push("in",inst, "OnClientEvent",table.pack(...))
377 end)
378 S.nListen += 1
379 elseif c == "RemoteFunction" then
380 wrapExisting(inst)
381 end
382end
383
384
385local function startTracking()
386 table.insert(S.conns, game.DescendantAdded:Connect(function(inst)
387 pcall(track, inst)
388 end))
389 task.spawn(function()
390 local ok, all = pcall(game.GetDescendants, game)
391 if not ok then return end
392 for i, inst in ipairs(all) do
393 if S.dead then return end
394 pcall(track, inst)
395 if i%2500 == 0 then task.wait() end
396 end
397 end)
398end
399
400local function disconnectAll()
401 for _, c in ipairs(S.conns) do pcall(c.Disconnect, c) end
402 S.conns = {}
403 for _,c in pairs(S.listeners) do pcall(c.Disconnect, c) end
404 S.listeners=weak()
405 S.nListen = 0
406end
407
408
409local function copy(text)
410 text = tostring(text)
411 local tries = {setclipboard, toclipboard, writeclipboard, syn and syn.write_clipboard}
412 for i = 1, 4 do
413 local f = tries[i]
414 if isfn(f) and pcall(f, text) then return true end
415 end
416 return false
417end
418
419local function saveFile(name, body)
420 if not can.writefile then return false, "writefile unavailable" end
421 if can.folders then
422 pcall(function() if not isfolder("LexSpy") then makefolder("LexSpy") end end)
423 end
424 local path="LexSpy/" .. name
425 local ok = pcall(writefile, path, body)
426 if ok then return true, path end
427 return false, "writefile failed"
428end
429
430local function quiet(fn)
431 local co = coroutine.running()
432 S.muted[co] = true
433 local res = table.pack(pcall(fn))
434 S.muted[co] = nil
435 return res
436end
437
438local function flash(btn,msg, back)
439 if not btn then return end
440 btn.Text = msg
441 task.delay(1.2, function() btn.Text = back end)
442end
443
444local function argList(e)
445 local out = {}
446 for i = 1, e.n do out[i] = ser(e.args[i], 0, {}, 10,true) end
447 return table.concat(out, ", ")
448end
449
450local function callText(e)
451 local path, m = pathExpr(e.remote), e.method
452 local params = e.n > 0 and "..." or ""
453 if m == "OnClientEvent" then
454 return ("%s.OnClientEvent:Connect(function(%s)\n -- captured %s\nend)"):format(path, params, e.stamp)
455 end
456 if m == "OnClientInvoke" then
457 return ("%s.OnClientInvoke = function(%s)\n -- captured %s\nend"):format(path, params,e.stamp)
458 end
459 return ("%s:%s(%s)"):format(path, m, argList(e))
460end
461
462local function editText(e)
463 if e.dir == "in" and e.method == "OnClientEvent" and can.fire then
464 local a = argList(e)
465
466 return ("firesignal(%s.OnClientEvent%s)"):format(pathExpr(e.remote), a ~= "" and (", " .. a) or "")
467 end
468 return callText(e)
469end
470
471local function detailText(e)
472 local path = fullPath(e.remote)
473 local L = {
474 "Remote : " .. path,
475 "Class : " .. e.remote.ClassName,
476 "Method : " .. e.method,
477 "Direction: " .. (e.dir == "in" and "INCOMING (server → client)" or "OUTGOING (client → server)"),
478 "Time : " .. e.stamp,
479 }
480 local nice = friendly(path)
481 if nice then table.insert(L, "Friendly : " .. nice) end
482 if e.blocked then table.insert(L,"Status : BLOCKED") end
483
484 table.insert(L,"")
485 table.insert(L, ("Arguments (%d):"):format(e.n))
486 if e.n == 0 then
487 table.insert(L, " (none)")
488 else
489 for i = 1, e.n do
490 table.insert(L, (" [%d] (%s)"):format(i, typeof(e.args[i])))
491 table.insert(L, " " .. ser(e.args[i]))
492 end
493 end
494
495 table.insert(L, "")
496 table.insert(L, "Generated:")
497 table.insert(L,callText(e))
498 return table.concat(L, "\n")
499end
500
501local renderDetail, genScript
502
503local function selected()
504 if not S.sel then return end
505 for _, e in ipairs(S.log) do
506 if e.id == S.sel then return e end
507 end
508end
509
510local UI = {}
511
512local C = {
513 bg = Color3.fromRGB(18, 18, 22),
514 bgAlt = Color3.fromRGB(24, 24, 30),
515 panel = Color3.fromRGB(28, 28, 35),
516 row = Color3.fromRGB(32, 32, 40),
517 rowSel = Color3.fromRGB(48, 70,110),
518 accent = Color3.fromRGB(90, 150, 255),
519 incoming = Color3.fromRGB(80, 220, 140),
520 outgoing = Color3.fromRGB(255, 170,60),
521 text = Color3.fromRGB(230, 230, 235),
522 dim = Color3.fromRGB(150, 150, 160),
523 danger=Color3.fromRGB(255, 80, 80),
524 gold = Color3.fromRGB(255,200,60),
525}
526
527local function new(class, props, parent)
528 local o = Instance.new(class)
529
530 for k, v in pairs(props or {}) do o[k] = v end
531 if parent then o.Parent = parent end
532 return o
533end
534
535local function corner(p, r)
536 return new("UICorner", {CornerRadius = UDim.new(0, r or 6)}, p)
537end
538
539local function stroke(p, color, thick, trans)
540 return new("UIStroke", {
541 Color = color or C.accent,
542 Thickness = thick or 1,
543 Transparency = trans or 0.5,
544 ApplyStrokeMode = Enum.ApplyStrokeMode.Border,
545 }, p)
546end
547
548local function btn(parent, text, color, size, pos)
549 local b = new("TextButton", {
550 Text = text, Font=Enum.Font.GothamBold, TextSize = 12, TextColor3 = C.text,
551 BackgroundColor3 = color or C.panel, BackgroundTransparency=0.15,
552 BorderSizePixel = 0, TextTruncate = Enum.TextTruncate.AtEnd,
553 Size=size, Position = pos,
554 }, parent)
555 corner(b, 5)
556 stroke(b, C.accent, 1,0.7)
557 return b
558end
559
560local W, H = 820, 540
561local TB_H = 68
562local EDIT_H, GRID_H=62, 86
563local function attach(gui, opener)
564 local targets={}
565 if typeof(CoreGui) == "Instance" then table.insert(targets, CoreGui) end
566 if can.hui then
567 local ok, h = pcall(gethui)
568 if ok and typeof(h) == "Instance" then table.insert(targets, h) end
569 end
570 local pg = plr and (plr:FindFirstChild("PlayerGui") or plr:WaitForChild("PlayerGui",5))
571 if pg then table.insert(targets, pg) end
572 for _, t in ipairs(targets) do
573 for _, n in ipairs({"LexRemoteSpy", "LexRemoteSpyOpener"}) do
574 local old = t:FindFirstChild(n)
575 if old then pcall(old.Destroy, old) end
576 end
577 end
578 for _, t in ipairs(targets) do
579 pcall(function() gui.Parent = t end)
580 if gui.Parent == t then
581 pcall(function() opener.Parent = t end)
582 return true
583 end
584 end
585 return false
586end
587
588local function refreshStatus()
589 if not UI.status then return end
590 local txt,col
591 if not S.on then
592 txt, col = "OFF", C.danger
593 elseif S.paused then
594 txt,col = "PAUSED", C.outgoing
595 else
596 txt, col = "ACTIVE", C.incoming
597 end
598 UI.status.Text = txt
599 UI.status.TextColor3 = col
600 UI.dot.BackgroundColor3 = col
601end
602
603local function resetDetail()
604 S.sel=nil
605 UI.detailBox.Text = ""
606 UI.detailTitle.Text = "Select an entry"
607 UI.editBox.Text = ""
608 UI.editId = nil
609end
610
611local function buildUI()
612 local gui = new("ScreenGui", {
613 Name = "LexRemoteSpy", ResetOnSpawn = false, DisplayOrder=999,
614 ZIndexBehavior = Enum.ZIndexBehavior.Sibling,
615 })
616 local opener = new("ScreenGui",{
617 Name = "LexRemoteSpyOpener", ResetOnSpawn = false, DisplayOrder = 999,
618 ZIndexBehavior = Enum.ZIndexBehavior.Sibling, Enabled = false,
619 })
620 UI.gui = gui
621 UI.opener=opener
622
623 local tab = new("TextButton", {
624 Text = "LEX", Font = Enum.Font.GothamBlack, TextSize = 12, TextColor3 = C.text,
625 BackgroundColor3 = C.bgAlt, BorderSizePixel = 0,
626 Size = UDim2.fromOffset(44, 28), Position = UDim2.new(0, 8, 0.5, -14),
627 }, opener)
628 corner(tab, 6)
629 stroke(tab, C.accent, 1, 0.4)
630 UI.setOpen = function(v)
631 gui.Enabled = v
632 opener.Enabled = not v
633 end
634 tab.MouseButton1Click:Connect(function() UI.setOpen(true) end)
635
636 local main = new("Frame", {
637 Name="Main", Size = UDim2.fromOffset(W,H),
638 Position = UDim2.new(0.5,-W/2, 0.5,-H/2),
639 BackgroundColor3 = C.bg, BorderSizePixel = 0, Active=true, Draggable = true,
640 }, gui)
641 corner(main, 10)
642 stroke(main, C.accent, 1, 0.4)
643
644
645 local hdr = new("Frame",{
646 Size = UDim2.new(1, 0, 0, 40), BackgroundColor3 = C.bgAlt, BorderSizePixel = 0,
647 }, main)
648 corner(hdr, 10)
649
650 new("TextLabel", {
651 Text = " REMOTE SPY", Font = Enum.Font.GothamBlack,TextSize = 16,TextColor3 = C.text,
652 BackgroundTransparency = 1, TextXAlignment = Enum.TextXAlignment.Left,
653 Size=UDim2.new(0, 160, 1, 0), Position = UDim2.new(0, 8,0, 0),
654 }, hdr)
655
656 UI.dot = new("Frame", {
657 Size = UDim2.fromOffset(10, 10),Position = UDim2.new(0, 172, 0.5, -5),
658 BackgroundColor3 = C.incoming, BorderSizePixel=0,
659 }, hdr)
660 corner(UI.dot, 5)
661
662 UI.status = new("TextLabel", {
663 Text = "ACTIVE",Font = Enum.Font.GothamBold, TextSize = 12,TextColor3 = C.incoming,
664 BackgroundTransparency = 1, TextXAlignment = Enum.TextXAlignment.Left,
665 Size = UDim2.new(0, 100, 1, 0), Position = UDim2.new(0, 188, 0, 0),
666 }, hdr)
667
668 local mode = isBB and "BB MODE" or "UNIVERSAL MODE"
669
670 if not S.hooked then mode = mode .. " (IN ONLY)" end
671 new("TextLabel", {
672 Text = mode, Font = Enum.Font.GothamBold,TextSize = 11,
673 TextColor3 = isBB and C.gold or C.dim,BackgroundTransparency = 1,
674 Size = UDim2.new(0, 240, 1, 0), Position=UDim2.new(0.5,-120, 0, 0),
675 TextXAlignment = Enum.TextXAlignment.Center,
676 }, hdr)
677
678 local closeBtn = new("TextButton", {
679 Text = "✕", Font = Enum.Font.GothamBold, TextSize = 16, TextColor3 = C.danger,
680 BackgroundTransparency = 1, Size = UDim2.fromOffset(40, 40), Position = UDim2.new(1,-40, 0, 0),
681 }, hdr)
682
683 local minBtn = new("TextButton",{
684 Text = "—", Font = Enum.Font.GothamBold, TextSize = 16, TextColor3 = C.dim,
685 BackgroundTransparency = 1,Size = UDim2.fromOffset(40, 40), Position = UDim2.new(1, -80,0, 0),
686 }, hdr)
687 local unloadBtn = new("TextButton", {
688 Text = "Unload", Font = Enum.Font.GothamBold,TextSize = 11, TextColor3 = C.dim,
689 BackgroundTransparency = 1, Size = UDim2.fromOffset(60,40), Position = UDim2.new(1, -150, 0, 0),
690 }, hdr)
691
692 local tb = new("Frame", {
693 Name = "Toolbar",Size = UDim2.new(1, 0, 0, TB_H), Position = UDim2.new(0, 0, 0, 40),
694 BackgroundColor3 = C.bgAlt, BorderSizePixel = 0,
695 },main)
696
697 local search = new("TextBox", {
698 Size = UDim2.new(0, 200, 0, 26), Position = UDim2.new(0, 8,0, 6),
699 BackgroundColor3 = C.panel, BorderSizePixel = 0, Text = "",
700 PlaceholderText = "Search remote name...", PlaceholderColor3 = C.dim,
701 Font = Enum.Font.Gotham, TextSize = 12, TextColor3 = C.text,
702 TextXAlignment = Enum.TextXAlignment.Left, ClearTextOnFocus = false,
703 },tb)
704 corner(search, 5)
705 stroke(search, C.accent, 1, 0.7)
706 search:GetPropertyChangedSignal("Text"):Connect(function()
707 S.query=search.Text
708 S.dirty = true
709 end)
710 UI.dirBtn = btn(tb, "All", C.panel, UDim2.fromOffset(80, 26), UDim2.new(0, 216, 0, 6))
711 UI.bbBtn = btn(tb, "BB Only", C.panel, UDim2.fromOffset(80, 26), UDim2.new(0, 302, 0, 6))
712 UI.pauseBtn = btn(tb, "Pause", C.panel, UDim2.fromOffset(70, 26), UDim2.new(0,388, 0, 6))
713 UI.scrollBtn = btn(tb, "AutoScroll ✓", C.rowSel,UDim2.fromOffset(90, 26), UDim2.new(0,464, 0,6))
714 if not S.autoscroll then
715 UI.scrollBtn.Text = "AutoScroll"
716 UI.scrollBtn.BackgroundColor3=C.panel
717 end
718
719 local exportBtn = btn(tb, "Export",C.panel, UDim2.fromOffset(70, 26), UDim2.new(1,-258, 0, 6))
720 local copyAllBtn = btn(tb, "Copy All", C.panel, UDim2.fromOffset(80,26), UDim2.new(1, -178,0,6))
721 local clearBtn = btn(tb, "Clear",C.panel, UDim2.fromOffset(70, 26), UDim2.new(1, -90, 0, 6))
722 local unignoreBtn = btn(tb, "Unignore All", C.panel, UDim2.fromOffset(100, 26), UDim2.new(0, 8, 0, 36))
723 local unblockBtn = btn(tb, "Unblock All", C.panel, UDim2.fromOffset(100, 26), UDim2.new(0, 114, 0, 36))
724 local capBtn = btn(tb,"Max: " .. S.cap, C.panel, UDim2.fromOffset(86, 26),UDim2.new(0, 220, 0, 36))
725
726 local body = new("Frame", {
727 Name = "Content", Size = UDim2.new(1, 0, 1, -40 - TB_H - 24),
728 Position = UDim2.new(0, 0, 0, 40 + TB_H), BackgroundColor3 = C.bg, BorderSizePixel = 0,
729 }, main)
730
731 local listBox=new("Frame", {
732 Size = UDim2.new(0.58, -8, 1, -8), Position = UDim2.new(0, 6, 0, 4),
733 BackgroundColor3 = C.bgAlt, BorderSizePixel = 0,
734 }, body)
735 corner(listBox, 8)
736
737 UI.list = new("ScrollingFrame", {
738 Size = UDim2.new(1, -8, 1, -8), Position = UDim2.new(0, 4, 0, 4),
739 BackgroundTransparency=1, BorderSizePixel = 0, ScrollBarThickness=6,
740 ScrollBarImageColor3 = C.accent, CanvasSize = UDim2.new(),
741 AutomaticCanvasSize = Enum.AutomaticSize.Y,
742 }, listBox)
743 new("UIListLayout", {Padding = UDim.new(0, 3),SortOrder = Enum.SortOrder.LayoutOrder}, UI.list)
744 new("UIPadding", {PaddingTop = UDim.new(0, 2), PaddingLeft = UDim.new(0, 2), PaddingRight = UDim.new(0, 2)}, UI.list)
745
746 local right = new("Frame", {
747 Size = UDim2.new(0.42, -8, 1,-8), Position = UDim2.new(0.58, 2, 0, 4),
748 BackgroundColor3 = C.bgAlt, BorderSizePixel = 0,
749 },body)
750 corner(right, 8)
751
752 UI.detailTitle=new("TextLabel", {
753 Text = "Select an entry", Font = Enum.Font.GothamBold, TextSize = 13, TextColor3 = C.text,
754 BackgroundTransparency = 1, TextXAlignment = Enum.TextXAlignment.Left,
755 Size = UDim2.new(1, -12,0, 26), Position = UDim2.new(0, 6, 0, 4),
756 }, right)
757
758 local scroll = new("ScrollingFrame", {
759 Size = UDim2.new(1, -12, 1, -(30 + 4+EDIT_H+4 + GRID_H + 4)),
760 Position = UDim2.new(0, 6, 0, 30), BackgroundColor3 = C.panel, BorderSizePixel = 0,
761 ScrollBarThickness = 6,ScrollBarImageColor3 = C.accent, CanvasSize = UDim2.new(),
762 AutomaticCanvasSize = Enum.AutomaticSize.Y,
763 },right)
764 corner(scroll, 6)
765
766 UI.detailBox=new("TextBox", {
767 Size = UDim2.new(1, -8, 0, 0), Position = UDim2.new(0, 4, 0, 4), BackgroundTransparency = 1,
768 Text="",Font = Enum.Font.Code, TextSize = 12, TextColor3 = C.text, TextWrapped = true,
769 TextXAlignment = Enum.TextXAlignment.Left, TextYAlignment = Enum.TextYAlignment.Top,
770 TextEditable = false, ClearTextOnFocus = false, AutomaticSize = Enum.AutomaticSize.Y,
771 }, scroll)
772
773 UI.editBox = new("TextBox", {
774 Name = "Editor", Size=UDim2.new(1, -12, 0, EDIT_H),
775 Position = UDim2.new(0, 6, 1, -(GRID_H + 8 + EDIT_H)),
776 BackgroundColor3 = C.panel, BorderSizePixel = 0,Text = "",
777 PlaceholderText = "Select an entry to load its call here, edit it, then press Run Edited",
778 PlaceholderColor3 = C.dim, Font = Enum.Font.Code, TextSize = 11, TextColor3 = C.text,
779 TextWrapped = true, MultiLine = true, ClearTextOnFocus = false, ClipsDescendants = true,
780 TextXAlignment = Enum.TextXAlignment.Left, TextYAlignment = Enum.TextYAlignment.Top,
781 }, right)
782 corner(UI.editBox,6)
783 stroke(UI.editBox, C.accent, 1,0.7)
784
785 local grid = new("Frame", {
786 Size = UDim2.new(1, -12, 0, GRID_H), Position = UDim2.new(0, 6, 1, -(GRID_H + 4)),
787 BackgroundTransparency = 1,
788 }, right)
789 new("UIGridLayout", {
790 CellSize = UDim2.new(1/3, -4,0, 26), CellPadding = UDim2.new(0, 6, 0, 4),
791 SortOrder = Enum.SortOrder.LayoutOrder,
792 }, grid)
793
794 UI.copyCall = btn(grid, "Copy Call")
795 UI.copyArgs = btn(grid, "Copy Args")
796 UI.copyPath = btn(grid, "Copy Path")
797 UI.fireBtn = btn(grid, "Fire Again")
798 UI.invokeBtn = btn(grid, "Invoke Again")
799 UI.runBtn = btn(grid, "Run Edited")
800
801 UI.blockBtn = btn(grid, "Block")
802 UI.ignoreBtn = btn(grid, "Ignore")
803 UI.onlyBtn = btn(grid, "Only This")
804 UI.removeBtn = btn(grid, "Remove", C.danger)
805 UI.fireLabel = "Fire Again"
806 UI.invokeBtn.Visible = false
807
808 local footer=new("Frame", {
809 Name = "Footer", Size = UDim2.new(1, 0, 0, 24), Position = UDim2.new(0, 0, 1, -24),
810 BackgroundColor3 = C.bgAlt, BorderSizePixel = 0,
811 }, main)
812
813 UI.stats = new("TextLabel", {
814 Text = "0 total | 0 in | 0 out | 0 blocked",Font=Enum.Font.Gotham,TextSize = 11,
815 TextColor3 = C.dim, BackgroundTransparency = 1, TextXAlignment = Enum.TextXAlignment.Left,
816 Size = UDim2.new(1, -16, 1, 0), Position = UDim2.new(0, 8, 0, 0),
817 }, footer)
818
819 closeBtn.MouseButton1Click:Connect(function() UI.setOpen(false) end)
820
821 local armed = false
822 unloadBtn.MouseButton1Click:Connect(function()
823 if not armed then
824 armed = true
825 unloadBtn.Text = "Sure?"
826 unloadBtn.TextColor3=C.danger
827 task.delay(2, function()
828 armed = false
829 unloadBtn.Text = "Unload"
830 unloadBtn.TextColor3 = C.dim
831 end)
832 return
833 end
834 if env.__LEXSPY_CLEANUP then env.__LEXSPY_CLEANUP() end
835 end)
836
837 minBtn.MouseButton1Click:Connect(function()
838 local open = main.Size.Y.Offset ~= 40
839 TS:Create(main, TweenInfo.new(0.18), {Size = UDim2.fromOffset(W, open and 40 or H)}):Play()
840 body.Visible = not open
841 footer.Visible = not open
842 tb.Visible = not open
843 end)
844
845 UI.dirBtn.MouseButton1Click:Connect(function()
846 local order = {"All","Incoming", "Outgoing"}
847 local at = table.find(order, S.dir) or 1
848 S.dir=order[at % #order+1]
849 UI.dirBtn.Text = S.dir
850 S.dirty = true
851 end)
852
853
854 UI.bbBtn.MouseButton1Click:Connect(function()
855 S.bbOnly = not S.bbOnly
856 UI.bbBtn.Text = S.bbOnly and "BB Only ✓" or "BB Only"
857 UI.bbBtn.BackgroundColor3 = S.bbOnly and C.rowSel or C.panel
858 S.dirty = true
859 end)
860
861 UI.pauseBtn.MouseButton1Click:Connect(function()
862 S.paused = not S.paused
863 UI.pauseBtn.Text = S.paused and "Resume" or "Pause"
864 UI.pauseBtn.BackgroundColor3 = S.paused and C.rowSel or C.panel
865 refreshStatus()
866 end)
867
868 UI.scrollBtn.MouseButton1Click:Connect(function()
869 S.autoscroll = not S.autoscroll
870 UI.scrollBtn.Text = S.autoscroll and "AutoScroll ✓" or "AutoScroll"
871 UI.scrollBtn.BackgroundColor3 = S.autoscroll and C.rowSel or C.panel
872 end)
873 clearBtn.MouseButton1Click:Connect(function()
874 S.log = {}
875 queue = {}
876 S.dirty = true
877 resetDetail()
878 end)
879 exportBtn.MouseButton1Click:Connect(function()
880 local fname = "remote_log_" .. os.date("%Y%m%d_%H%M%S") .. ".lua"
881 local ok, where = saveFile(fname, genScript(S.log))
882 if ok then print(TAG .. "saved " .. tostring(where)) end
883 flash(exportBtn, ok and "Saved ✓" or "No writefile", "Export")
884 end)
885
886 unignoreBtn.MouseButton1Click:Connect(function()
887 S.ignored = {}
888 S.dirty = true
889 renderDetail()
890 flash(unignoreBtn, "Done ✓", "Unignore All")
891 end)
892
893 unblockBtn.MouseButton1Click:Connect(function()
894 S.blocked = {}
895 S.dirty = true
896 renderDetail()
897 flash(unblockBtn, "Done ✓", "Unblock All")
898 end)
899
900 capBtn.MouseButton1Click:Connect(function()
901 local sizes={200, 600, 1500, 3000}
902 local at = table.find(sizes, S.cap) or 0
903 S.cap = sizes[at%#sizes + 1]
904 capBtn.Text = "Max: " .. S.cap
905 trimLog()
906 S.dirty = true
907 end)
908
909
910 copyAllBtn.MouseButton1Click:Connect(function()
911 flash(copyAllBtn, copy(genScript(S.log)) and "Copied ✓" or "No clipboard", "Copy All")
912 end)
913
914 UI.copyCall.MouseButton1Click:Connect(function()
915 local e = selected()
916 if not e then return end
917 flash(UI.copyCall, copy(callText(e)) and "Copied ✓" or "No clipboard", "Copy Call")
918 end)
919
920 UI.copyArgs.MouseButton1Click:Connect(function()
921 local e = selected()
922 if not e then return end
923 local parts = {}
924 for i = 1, e.n do parts[i] = ser(e.args[i], 0, {}, 10, true) end
925 flash(UI.copyArgs, copy(table.concat(parts, ",\n")) and "Copied ✓" or "No clipboard", "Copy Args")
926 end)
927
928 UI.copyPath.MouseButton1Click:Connect(function()
929 local e = selected()
930 if not e then return end
931 flash(UI.copyPath, copy(fullPath(e.remote)) and "Copied ✓" or "No clipboard", "Copy Path")
932 end)
933
934
935
936 UI.fireBtn.MouseButton1Click:Connect(function()
937 local e = selected()
938 if not e or not isEvent(e.remote) then return end
939 local res
940 if e.dir=="in" then
941 if not can.fire then return end
942 res = quiet(function() firesignal(e.remote.OnClientEvent, unpack(e.args, 1, e.n)) end)
943 else
944 res = quiet(function() e.remote:FireServer(unpack(e.args, 1, e.n)) end)
945 end
946 flash(UI.fireBtn,res[1] and "Fired ✓" or "Error", UI.fireLabel)
947 end)
948
949 UI.invokeBtn.MouseButton1Click:Connect(function()
950 local e = selected()
951 if not e or e.dir ~= "out" or not isFunc(e.remote) then return end
952 local res = quiet(function() return e.remote:InvokeServer(unpack(e.args, 1, e.n)) end)
953 if S.sel==e.id then
954 if res[1] then
955 local out = {}
956 for i = 2, res.n do table.insert(out, ser(res[i])) end
957 UI.detailBox.Text = UI.detailBox.Text .. "\n\n-- InvokeServer returned:\n" .. (#out > 0 and table.concat(out, ",\n") or "(nothing)")
958 else
959 UI.detailBox.Text = UI.detailBox.Text .. "\n\n-- InvokeServer error:\n" .. tostring(res[2])
960 end
961 end
962 flash(UI.invokeBtn, res[1] and "Invoked ✓" or "Error", "Invoke Again")
963 end)
964
965 UI.runBtn.MouseButton1Click:Connect(function()
966 local src = UI.editBox.Text
967 if not src:find("%S") then return end
968 if not can.loadstr then
969 flash(UI.runBtn, "No loadstring", "Run Edited")
970 return
971 end
972 local id = S.sel
973 local fn, cerr = loadstring(src)
974 if not fn then
975 if S.sel == id then
976 UI.detailBox.Text = UI.detailBox.Text .. "\n\n-- Run Edited: syntax error\n" .. tostring(cerr)
977 end
978 flash(UI.runBtn, "Syntax error", "Run Edited")
979 return
980 end
981 local res = quiet(fn)
982
983 if S.sel == id then
984 if res[1] then
985 local out = {}
986 for i = 2, res.n do out[#out+1] = ser(res[i]) end
987 UI.detailBox.Text = UI.detailBox.Text .. "\n\n-- Run Edited: ok" .. (#out > 0 and ("\n" .. table.concat(out, ",\n")) or "")
988 else
989 UI.detailBox.Text = UI.detailBox.Text .. "\n\n-- Run Edited: error\n" .. tostring(res[2])
990 end
991 end
992 flash(UI.runBtn,res[1] and "Ran ✓" or "Error", "Run Edited")
993 end)
994
995 UI.blockBtn.MouseButton1Click:Connect(function()
996 local e = selected()
997 if not e then return end
998 if S.blocked[e.remote] then
999 S.blocked[e.remote] = nil
1000 else
1001 S.blocked[e.remote]=true
1002 end
1003 S.dirty = true
1004 renderDetail()
1005 end)
1006
1007 UI.ignoreBtn.MouseButton1Click:Connect(function()
1008 local e = selected()
1009 if not e then return end
1010 S.ignored[e.remote] = not S.ignored[e.remote] or nil
1011 S.dirty = true
1012 renderDetail()
1013 end)
1014 UI.onlyBtn.MouseButton1Click:Connect(function()
1015 local e = selected()
1016 if not e then return end
1017 local nm=""
1018 pcall(function() nm=e.remote.Name end)
1019 search.Text = nm
1020 end)
1021
1022 UI.removeBtn.MouseButton1Click:Connect(function()
1023 local e = selected()
1024 if not e then return end
1025 for i, v in ipairs(S.log) do
1026 if v.id == e.id then
1027 table.remove(S.log, i)
1028 break
1029 end
1030 end
1031 S.dirty = true
1032 resetDetail()
1033 end)
1034
1035 table.insert(S.conns,UIS.InputBegan:Connect(function(input, gp)
1036 if gp then return end
1037 if input.KeyCode==Enum.KeyCode.RightControl then
1038 UI.setOpen(not gui.Enabled)
1039 end
1040 end))
1041
1042 if not attach(gui, opener) then
1043 pcall(gui.Destroy, gui)
1044 pcall(opener.Destroy, opener)
1045 UI.gui = nil
1046 UI.opener = nil
1047 error("no usable GUI parent (CoreGui / gethui / PlayerGui all refused)")
1048 end
1049end
1050
1051local function passes(e)
1052 if S.dir == "Incoming" and e.dir ~= "in" then return false end
1053 if S.dir == "Outgoing" and e.dir ~= "out" then return false end
1054 if S.bbOnly and not fullPath(e.remote):find("ReplicatedStorage.Remotes", 1, true) then
1055 return false
1056 end
1057 if S.query ~= "" then
1058 local q = S.query:lower()
1059 if not (fullPath(e.remote):lower():find(q, 1, true) or e.method:lower():find(q, 1, true)) then
1060 return false
1061 end
1062 end
1063 return true
1064end
1065
1066local rows = {}
1067
1068local function getRow(i)
1069 if rows[i] then return rows[i] end
1070 local row = new("TextButton", {
1071 Size=UDim2.new(1, -4, 0, 26), BackgroundColor3 = C.row, BorderSizePixel = 0,
1072 Text = "", AutoButtonColor = false,
1073 },UI.list)
1074 corner(row, 4)
1075
1076 local stripe = new("Frame",{
1077 Size = UDim2.fromOffset(3, 18), Position=UDim2.new(0, 4,0.5, -9),
1078 BackgroundColor3 = C.incoming, BorderSizePixel = 0,
1079 }, row)
1080 corner(stripe, 2)
1081 local txt = new("TextLabel", {
1082 Size = UDim2.new(1, -16, 1, 0), Position = UDim2.new(0, 12, 0, 0), BackgroundTransparency = 1,
1083 Text = "", Font = Enum.Font.Gotham,TextSize = 11, TextColor3 = C.text,
1084 TextXAlignment = Enum.TextXAlignment.Left, TextTruncate = Enum.TextTruncate.AtEnd,
1085 }, row)
1086
1087 local item = {row = row, stripe=stripe, txt = txt}
1088 row.MouseButton1Click:Connect(function()
1089 if item.id then
1090 S.sel = item.id
1091 S.dirty=true
1092 renderDetail()
1093 end
1094 end)
1095 rows[i] = item
1096 return item
1097end
1098
1099local function rebuildList()
1100 if not UI.list then return end
1101
1102 local shown = {}
1103 for i=#S.log, 1,-1 do
1104 if passes(S.log[i]) then shown[#shown+1] = S.log[i] end
1105 end
1106 local count = math.min(#shown, 250)
1107
1108
1109 for i = 1, count do
1110 local e = shown[i]
1111 local item = getRow(i)
1112 item.row.Visible = true
1113 item.row.LayoutOrder = i
1114 item.row.BackgroundColor3 = e.id == S.sel and C.rowSel or C.row
1115 item.stripe.BackgroundColor3 = e.dir == "in" and C.incoming or C.outgoing
1116 item.id = e.id
1117
1118 if not e.rowText then
1119 local path = fullPath(e.remote)
1120 e.nice = friendly(path) ~= nil
1121 e.rowText = ("[%s] %s %s %s %s"):format(e.dir == "in" and "IN " or "OUT",e.stamp,shortPath(path), e.method, preview(e.args, e.n))
1122 end
1123 local text = e.rowText
1124 if e.nice then text = "★ " .. text end
1125 if e.blocked then text="[BLOCKED] " .. text end
1126 item.txt.Text = text
1127 end
1128 for i = count + 1, #rows do rows[i].row.Visible = false end
1129
1130 if S.autoscroll then UI.list.CanvasPosition = Vector2.new(0, 0) end
1131
1132 local nIn,nOut, nBlocked = 0, 0, 0
1133 for _,e in ipairs(S.log) do
1134 if e.dir == "in" then nIn += 1 else nOut += 1 end
1135 if S.blocked[e.remote] then nBlocked += 1 end
1136 end
1137 UI.stats.Text=("%d total | %d in | %d out | %d blocked | %d shown | out-hook: %s | listening: %d"):format(
1138 #S.log, nIn, nOut, nBlocked, count,S.hooked and "on" or "OFF", S.nListen)
1139end
1140
1141function renderDetail()
1142 local e=selected()
1143 if not e then
1144 UI.detailTitle.Text = "Select an entry"
1145 UI.detailBox.Text = ""
1146 if UI.editBox then
1147 UI.editBox.Text = ""
1148 UI.editId = nil
1149 end
1150 return
1151 end
1152 local path = fullPath(e.remote)
1153 UI.detailTitle.Text = (friendly(path) or shortPath(path)) .. " — " .. e.method
1154 UI.detailBox.Text = detailText(e)
1155
1156 UI.blockBtn.Text = S.blocked[e.remote] and "Unblock" or "Block"
1157 UI.ignoreBtn.Text = S.ignored[e.remote] and "Unignore" or "Ignore"
1158
1159 local out = e.dir == "out"
1160 UI.fireLabel=out and "Fire Again" or "Fire Client"
1161 UI.fireBtn.Text = UI.fireLabel
1162 UI.fireBtn.Visible = isEvent(e.remote) and (out or can.fire)
1163 UI.invokeBtn.Visible = out and isFunc(e.remote)
1164
1165 if UI.editId ~= e.id then
1166 UI.editBox.Text = editText(e)
1167 UI.editId = e.id
1168 end
1169end
1170
1171function genScript(list)
1172 local L={"-- Generated by LEX Remote Spy", "-- " .. os.date("%Y-%m-%d %H:%M:%S"), ""}
1173 for _, e in ipairs(list) do
1174 if passes(e) then
1175 table.insert(L,"-- [" .. e.stamp .. "] " .. e.method)
1176 table.insert(L, callText(e))
1177 table.insert(L, "")
1178 end
1179 end
1180 return table.concat(L,"\n")
1181end
1182
1183local lastDraw=0
1184
1185local function drain()
1186 if #queue == 0 then return end
1187 local batch = queue
1188 queue = {}
1189 for _, raw in ipairs(batch) do
1190 table.insert(S.log, {
1191 id=S.nextId, dir = raw.dir, remote = raw.remote, method = raw.method,
1192 args = raw.args, n = raw.n, stamp=raw.stamp,
1193 blocked = S.blocked[raw.remote] == true,
1194 })
1195 S.nextId += 1
1196 end
1197 trimLog()
1198 S.dirty = true
1199end
1200
1201local beat = RunService.Heartbeat:Connect(function()
1202 drain()
1203 local now = os.clock()
1204 if S.dirty and now - lastDraw > 0.12 then
1205 lastDraw = now
1206 S.dirty = false
1207 pcall(rebuildList)
1208 end
1209end)
1210
1211env.LexSpy = {
1212 Toggle = function(state)
1213 S.on = state ~= false
1214 refreshStatus()
1215 end,
1216 Clear = function()
1217 S.log = {}
1218 queue = {}
1219 S.sel = nil
1220 S.dirty=true
1221 end,
1222 GetLog = function()
1223 local out = {}
1224 for i, e in ipairs(S.log) do out[i]=e end
1225 return out
1226 end,
1227 Block = function(r) S.blocked[r] = true end,
1228 Unblock = function(r) S.blocked[r] = nil end,
1229 Ignore = function(r) S.ignored[r] = true end,
1230 Unignore = function(r) S.ignored[r]=nil end,
1231 GenerateScript = function() return genScript(S.log) end,
1232 SaveLog = function(name) return saveFile(name or "remote_log.lua",genScript(S.log)) end,
1233 SetFilter = function(f) S.dir = f; S.dirty = true end,
1234 SetBBOnly = function(v) S.bbOnly = v; S.dirty = true end,
1235 Show = function(v) if UI.setOpen then UI.setOpen(v ~= false) end end,
1236 Unload = function() if env.__LEXSPY_CLEANUP then env.__LEXSPY_CLEANUP() end end,
1237}
1238
1239env.__LEXSPY_CLEANUP=function()
1240 env.__LEXSPY_LOADED = false
1241 S.on = false
1242 S.dead=true
1243 if beat then pcall(beat.Disconnect, beat) end
1244 disconnectAll()
1245 removeHooks()
1246 if UI.gui then pcall(UI.gui.Destroy, UI.gui) end
1247
1248 if UI.opener then pcall(UI.opener.Destroy, UI.opener) end
1249 queue = {}
1250 rows = {}
1251 S.log = {}
1252 env.LexSpy = nil
1253 print(TAG .. "unloaded")
1254end
1255
1256do
1257 local called, ok, err = pcall(installHooks)
1258 if not called then
1259 err = ok
1260 ok = false
1261 end
1262 S.hooked = ok == true
1263 if not S.hooked then
1264 warn(TAG .. "hook install failed (incoming still works): " .. tostring(err))
1265 end
1266
1267 local uiOk, uiErr = pcall(buildUI)
1268 if not uiOk then warn(TAG .. "UI build failed: " .. tostring(uiErr)) end
1269
1270 local trOk, trErr = pcall(startTracking)
1271 if not trOk then warn(TAG .. "remote tracking failed: " .. tostring(trErr)) end
1272
1273 task.defer(function()
1274 S.dirty = true
1275 pcall(rebuildList)
1276 end)
1277
1278 print(("%sloaded in %.0fms | bb: %s | out-hook: %s"):format(TAG, (os.clock() - t0)*1000,tostring(isBB), tostring(S.hooked)))
1279end