Dark Spawner Script
HomeGamesTrendingExecutors
Dark Spawner Script

The best community driven platform for finding the latest Roblox scripts. Create, share, and discover amazing scripts.

Scripts
695+
Games
441+
Votes cast
8,319+

Quick Links

  • How to Use
  • Games
  • Trending Scripts
  • Executors
  • FAQs

Community

Links coming soon.

Contact

  • [email protected]
  • Report a script

© 2026 Dark Spawner Script. All rights reserved.

About UsPrivacy PolicyDisclaimer
Home›Games›Towers of Fortune

Towers of Fortune Script Lunyx Hub: Kill Aura, ESP

Towers of Fortune•1 day ago
15 views
Towers of Fortune Script Lunyx Hub: Kill Aura, ESP
No Key
  • Working
  • updated 1 day ago
  • No key
  • tested on Delta, Xeno
T

Team Darkspawner

Hub: Lunyx Hub

Play Game Game Link

Description

Use this Lunyx Hub for Towers of Fortune Roblox!! Now you can get features like Kill Aura, Hitbox Expander, Fly, ESP and Auto Hit, and More!! The window runs on tabs for Combat, Visuals, Movement, World and Config, and Combat opens with KillAura switched on, its Range slider set to 40 and ESP on right below it. World keeps teleports to the arena center, the lobby spawn and the nearest enemy, plus Anti AFK, Rejoin server and Server hop. The author built it for Delta on mobile and says it works on desktop too, and you tap the round L bubble to hide or show the hub. No key on this one, so paste the loadstring and go!!

Features

  • +ESP with Names, Health and Distance
  • +Kill Aura
  • +Infinite Jump
  • +Hitbox Expander
  • +Teleport to Arena, Lobby and Nearest Enemy
  • +Aim Assist with Wall Check
  • +Fly
  • +Tracers
  • +Auto Hit with Reach
  • +Anti AFK and Server Hop
  • +Chams
  • +Speed Boost
  • +Fullbright and No Fog
  • +FOV Circle
Towers of Fortune

Towers of Fortune

Explore more scripts for this game (1)

Script

Raw Download
--[[
	LUNYX HUB v2 // Towers of Fortune
	Executor : Delta (built for mobile, works on desktop)
	PlaceId  : 108114331578868
	Tabs     : Combat | Visuals | Movement | World | Config | Probe | Settings
	Tap the round L bubble to hide or show the hub. Drag the title bar to move it.
	Re-running the script replaces the old hub, nothing stacks.
]]

local env = (getgenv and getgenv()) or _G
if env.__LUNYX_TOF and type(env.__LUNYX_TOF.Destroy) == "function" then
	pcall(env.__LUNYX_TOF.Destroy)
end

---------------------------------------------------------------------
-- services / basics
---------------------------------------------------------------------
local function svc(name)
	local ok, s = pcall(game.GetService, game, name)
	if not ok or not s then return nil end
	if cloneref then
		local ok2, c = pcall(cloneref, s)
		if ok2 and c then return c end
	end
	return s
end

local Players = svc("Players")
local RunService = svc("RunService")
local UserInputService = svc("UserInputService")
local TweenService = svc("TweenService")
local Lighting = svc("Lighting")
local ReplicatedStorage = svc("ReplicatedStorage")
local TeleportService = svc("TeleportService")
local HttpService = svc("HttpService")
local CoreGui = svc("CoreGui")
local VirtualUser = svc("VirtualUser")
local VirtualInputManager = svc("VirtualInputManager")
local Stats = svc("Stats")

local LP = Players.LocalPlayer
local alive = true
local conns, cleanups = {}, {}

local function keep(c) conns[#conns + 1] = c; return c end
local function onClean(f) cleanups[#cleanups + 1] = f end
local function cam() return workspace.CurrentCamera end
local function clamp(v, a, b) return math.max(a, math.min(b, v)) end
local function myRoot() local c = LP.Character; return c and c:FindFirstChild("HumanoidRootPart") end
local function myHum() local c = LP.Character; return c and c:FindFirstChildOfClass("Humanoid") end
local function wsFind(...)
	local cur = workspace
	for _, n in ipairs({ ... }) do cur = cur and cur:FindFirstChild(n) end
	return cur
end

---------------------------------------------------------------------
-- state
---------------------------------------------------------------------
local S = {
	aim = { on = false, fov = 160, smooth = 0.35, part = "Head", wall = true, plrs = true, bots = true, circle = true },
	trig = { on = false, reach = 12, delay = 0.15, radius = 55 },
	hit = { on = false, size = 6, part = "HumanoidRootPart" },
	esp = { on = false, box = true, name = true, hp = true, dist = true, tracer = false, chams = false, plrs = true, bots = true, maxd = 600, color = 1 },
	vis = { full = false, fog = false, clean = false, fov = false, fovv = 90 },
	mov = { speed = false, speedv = 16, fly = false, flyv = 60, ijump = false, hum = false, ws = 24, jp = 60 },
	misc = { afk = true },
	probe = { spy = false, spam = false },
	ui = { scale = 1, accent = 1, watermark = true, active = true, notify = true },
}

local FEATURES = {
	{ "Aim assist", function() return S.aim.on end },
	{ "Auto hit", function() return S.trig.on end },
	{ "Hitbox", function() return S.hit.on end },
	{ "ESP", function() return S.esp.on end },
	{ "Fullbright", function() return S.vis.full end },
	{ "No fog", function() return S.vis.fog end },
	{ "No post FX", function() return S.vis.clean end },
	{ "Custom FOV", function() return S.vis.fov end },
	{ "Speed boost", function() return S.mov.speed end },
	{ "Humanoid override", function() return S.mov.hum end },
	{ "Fly", function() return S.mov.fly end },
	{ "Infinite jump", function() return S.mov.ijump end },
	{ "Anti-AFK", function() return S.misc.afk end },
}

local PALETTE = {
	{ "Crimson", Color3.fromRGB(255, 72, 96) },
	{ "Cyan", Color3.fromRGB(70, 210, 255) },
	{ "Lime", Color3.fromRGB(110, 255, 140) },
	{ "Violet", Color3.fromRGB(150, 110, 255) },
	{ "Gold", Color3.fromRGB(255, 205, 80) },
	{ "White", Color3.fromRGB(240, 240, 250) },
}
local BOT_COLOR = Color3.fromRGB(255, 160, 60)

---------------------------------------------------------------------
-- targets (cached at 20 Hz, shared by aim / trigger / ESP / hitbox)
---------------------------------------------------------------------
local tCache, tStamp = {}, 0

local function aliveModel(m)
	local h = m:FindFirstChildOfClass("Humanoid")
	local r = m:FindFirstChild("HumanoidRootPart")
	if h and r and h.Health > 0 then return h, r end
end

local function allTargets()
	local now = os.clock()
	if now - tStamp < 0.05 then return tCache end
	tStamp = now
	local out, mine = {}, LP.Character
	for _, p in ipairs(Players:GetPlayers()) do
		local ch = p.Character
		if p ~= LP and ch and ch ~= mine and p:GetAttribute("Spectating") ~= true then
			local h, r = aliveModel(ch)
			if h then out[#out + 1] = { model = ch, hum = h, root = r, name = p.Name, bot = false } end
		end
	end
	local f = workspace:FindFirstChild("Bots")
	if f then
		for _, m in ipairs(f:GetChildren()) do
			if m:IsA("Model") and m.Name ~= "Shopkeeper" then
				local h, r = aliveModel(m)
				if h then out[#out + 1] = { model = m, hum = h, root = r, name = m.Name, bot = true } end
			end
		end
	end
	tCache = out
	return out
end

local function listTargets(wantPlayers, wantBots)
	local out = {}
	for _, t in ipairs(allTargets()) do
		if ((t.bot and wantBots) or (not t.bot and wantPlayers)) and t.root.Parent and t.hum.Health > 0 then
			out[#out + 1] = t
		end
	end
	return out
end

local function aimPart(t, name)
	return t.model:FindFirstChild(name) or t.root
end

local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Exclude
rayParams.IgnoreWater = true
local ignoreList, ignoreStamp = {}, 0
local IGNORE_PATHS = { { "Bots" }, { "MCFx" }, { "Drops" }, { "Chicks" }, { "MCLocal" }, { "Mounts" }, { "Map", "Fluids" } }

local function visible(c, t, part)
	local now = os.clock()
	if now - ignoreStamp > 1 then
		ignoreStamp = now
		ignoreList = {}
		for _, path in ipairs(IGNORE_PATHS) do
			local inst = wsFind(table.unpack(path))
			if inst then ignoreList[#ignoreList + 1] = inst end
		end
	end
	local ex = { c, t.model }
	if LP.Character then ex[#ex + 1] = LP.Character end
	for _, i in ipairs(ignoreList) do ex[#ex + 1] = i end
	rayParams.FilterDescendantsInstances = ex
	local origin = c.CFrame.Position
	return workspace:Raycast(origin, part.Position - origin, rayParams) == nil
end

---------------------------------------------------------------------
-- UI kit
---------------------------------------------------------------------
local T = {
	bg = Color3.fromRGB(13, 14, 20),
	side = Color3.fromRGB(17, 18, 26),
	card = Color3.fromRGB(22, 24, 34),
	cardHi = Color3.fromRGB(32, 35, 49),
	line = Color3.fromRGB(44, 47, 66),
	text = Color3.fromRGB(238, 240, 250),
	sub = Color3.fromRGB(148, 154, 178),
	dim = Color3.fromRGB(96, 102, 126),
	good = Color3.fromRGB(70, 220, 140),
	bad = Color3.fromRGB(255, 82, 104),
	warn = Color3.fromRGB(255, 190, 80),
}
local FONT, FONTB = Enum.Font.GothamMedium, Enum.Font.GothamBold
local WHITE = Color3.new(1, 1, 1)

local function new(class, props, parent)
	local inst = Instance.new(class)
	if props then
		for k, v in pairs(props) do inst[k] = v end
	end
	if parent then inst.Parent = parent end
	return inst
end
local function corner(p, r) return new("UICorner", { CornerRadius = UDim.new(0, r or 8) }, p) end
local function stroke(p, c, th, tr)
	return new("UIStroke", { Color = c or T.line, Thickness = th or 1, Transparency = tr or 0, ApplyStrokeMode = Enum.ApplyStrokeMode.Border }, p)
end
local function tween(o, t, props, style, dir)
	local tw = TweenService:Create(o, TweenInfo.new(t, style or Enum.EasingStyle.Quad, dir or Enum.EasingDirection.Out), props)
	tw:Play()
	return tw
end

local ACCENTS = {
	{ "Violet", Color3.fromRGB(140, 100, 255), Color3.fromRGB(80, 130, 255) },
	{ "Ocean", Color3.fromRGB(40, 170, 255), Color3.fromRGB(70, 110, 255) },
	{ "Rose", Color3.fromRGB(255, 80, 140), Color3.fromRGB(255, 120, 90) },
	{ "Mint", Color3.fromRGB(30, 190, 140), Color3.fromRGB(40, 150, 220) },
	{ "Amber", Color3.fromRGB(240, 150, 30), Color3.fromRGB(235, 85, 70) },
}
local A1, A2 = ACCENTS[1][2], ACCENTS[1][3]
local accentFns = {}
local function onAccent(fn)
	accentFns[#accentFns + 1] = fn
	fn(A1, A2)
end
local function setAccent(i)
	local a = ACCENTS[i]
	A1, A2 = a[2], a[3]
	for _, fn in ipairs(accentFns) do pcall(fn, A1, A2) end
end
local function gradient(parent, rot)
	local g = new("UIGradient", { Rotation = rot or 0 }, parent)
	onAccent(function(a, b) g.Color = ColorSequence.new(a, b) end)
	return g
end
local function rgbStr(c)
	return string.format("rgb(%d,%d,%d)", math.floor(c.R * 255 + 0.5), math.floor(c.G * 255 + 0.5), math.floor(c.B * 255 + 0.5))
end

local function mount(g)
	pcall(function() if syn and syn.protect_gui then syn.protect_gui(g) end end)
	local ok = pcall(function() g.Parent = (gethui and gethui()) or CoreGui end)
	if not ok or not g.Parent then g.Parent = LP:WaitForChild("PlayerGui") end
end

-- drawing layer (FOV circle, tracers): viewport coordinates
local Draw = new("ScreenGui", { Name = "LunyxDraw", ResetOnSpawn = false, IgnoreGuiInset = true, DisplayOrder = 9990, ZIndexBehavior = Enum.ZIndexBehavior.Sibling })
-- interface layer
local Gui = new("ScreenGui", { Name = "LunyxToF", ResetOnSpawn = false, IgnoreGuiInset = true, DisplayOrder = 9999, ZIndexBehavior = Enum.ZIndexBehavior.Sibling })
mount(Draw)
mount(Gui)
local host = Gui.Parent

local overlay = new("Frame", { Name = "Overlay", BackgroundTransparency = 1, Size = UDim2.new(1, 0, 1, 0), BorderSizePixel = 0 }, Draw)
local circle = new("Frame", { AnchorPoint = Vector2.new(0.5, 0.5), BackgroundTransparency = 1, Visible = false, BorderSizePixel = 0 }, overlay)
corner(circle, 9999)
local circleStroke = stroke(circle, T.text, 1.5, 0.2)
onAccent(function(a) circleStroke.Color = a end)

-- window root ----------------------------------------------------------------
local WIN_W, WIN_H = 560, 330
local Root = new("Frame", {
	Name = "Root", AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.new(0.5, 0, 0.5, 0),
	Size = UDim2.fromOffset(WIN_W, WIN_H), BackgroundTransparency = 1,
}, Gui)
local RootScale = new("UIScale", { Scale = 1 }, Root)
new("ImageLabel", {
	AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.new(0.5, 0, 0.5, 8), Size = UDim2.new(1, 64, 1, 64), BackgroundTransparency = 1,
	Image = "rbxassetid://1316045217", ImageColor3 = Color3.new(0, 0, 0), ImageTransparency = 0.4, ScaleType = Enum.ScaleType.Slice,
	SliceCenter = Rect.new(10, 10, 118, 118), ZIndex = 0,
}, Root)
local Win = new("Frame", { Name = "Win", Size = UDim2.new(1, 0, 1, 0), BackgroundColor3 = WHITE, BorderSizePixel = 0, ClipsDescendants = true, Active = true, ZIndex = 1 }, Root)
corner(Win, 16)
new("UIGradient", { Color = ColorSequence.new(Color3.fromRGB(17, 18, 26), Color3.fromRGB(11, 12, 17)), Rotation = 90 }, Win)
local winStroke = stroke(Win, WHITE, 1.2, 0.3)
do
	local g = new("UIGradient", { Rotation = 35 }, winStroke)
	onAccent(function(a, b)
		g.Color = ColorSequence.new({ ColorSequenceKeypoint.new(0, a), ColorSequenceKeypoint.new(0.5, T.line), ColorSequenceKeypoint.new(1, b) })
	end)
end

local hubOpen = true
local fitScale = 1
local function clampRoot()
	local c = cam()
	if not c then return end
	local vp = c.ViewportSize
	local s = RootScale.Scale
	local half = Root.AbsoluteSize / 2
	local ctr = Root.AbsolutePosition + half
	local nx = clamp(ctr.X, math.min(half.X, vp.X / 2), math.max(vp.X - half.X, vp.X / 2))
	local ny = clamp(ctr.Y, math.min(half.Y, vp.Y / 2), math.max(vp.Y - half.Y, vp.Y / 2))
	local p = Root.Position
	Root.Position = UDim2.new(p.X.Scale, p.X.Offset + (nx - ctr.X) / s, p.Y.Scale, p.Y.Offset + (ny - ctr.Y) / s)
end
local function rescale()
	local c = cam()
	if not c then return end
	local vp = c.ViewportSize
	fitScale = clamp(math.min(vp.X / (WIN_W + 30), vp.Y / (WIN_H + 24)), 0.55, 1.15)
	RootScale.Scale = fitScale * S.ui.scale
	task.defer(clampRoot)
end
rescale()
if cam() then keep(cam():GetPropertyChangedSignal("ViewportSize"):Connect(rescale)) end

local function makeDraggable(handle, target, onTap, onEnd)
	local dragging, moved, startIn, startPos = false, false, nil, nil
	keep(handle.InputBegan:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
			dragging, moved = true, false
			startIn, startPos = input.Position, target.Position
			local ch
			ch = input.Changed:Connect(function()
				if input.UserInputState == Enum.UserInputState.End then
					dragging = false
					ch:Disconnect()
					if not moved and onTap then onTap() end
					if moved and onEnd then onEnd() end
				end
			end)
		end
	end))
	keep(UserInputService.InputChanged:Connect(function(input)
		if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
			local d = input.Position - startIn
			if d.Magnitude > 6 then moved = true end
			if moved then
				local sc = target:FindFirstChildOfClass("UIScale")
				local k = sc and sc.Scale or 1
				target.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + d.X / k, startPos.Y.Scale, startPos.Y.Offset + d.Y / k)
			end
		end
	end))
end

-- sidebar ---------------------------------------------------------------------
local SIDE_W = 140
local Side = new("Frame", { Size = UDim2.new(0, SIDE_W, 1, 0), BackgroundColor3 = T.side, BorderSizePixel = 0 }, Win)
new("Frame", { Size = UDim2.new(0, 1, 1, 0), Position = UDim2.new(1, -1, 0, 0), BackgroundColor3 = T.line, BackgroundTransparency = 0.3, BorderSizePixel = 0 }, Side)

local Brand = new("Frame", { Size = UDim2.new(1, 0, 0, 64), BackgroundTransparency = 1, Active = true }, Side)
local logo = new("Frame", { Size = UDim2.fromOffset(36, 36), Position = UDim2.fromOffset(14, 14), BackgroundColor3 = WHITE, BorderSizePixel = 0 }, Brand)
corner(logo, 11)
gradient(logo, 45)
new("TextLabel", { Text = "L", Font = FONTB, TextSize = 20, TextColor3 = WHITE, BackgroundTransparency = 1, Size = UDim2.new(1, 0, 1, 0) }, logo)
new("TextLabel", { Text = "LUNYX", Font = FONTB, TextSize = 15, TextColor3 = T.text, BackgroundTransparency = 1, TextXAlignment = Enum.TextXAlignment.Left, Position = UDim2.fromOffset(58, 15), Size = UDim2.new(1, -62, 0, 18) }, Brand)
new("TextLabel", { Text = "Towers of Fortune", Font = FONT, TextSize = 10, TextColor3 = T.dim, BackgroundTransparency = 1, TextXAlignment = Enum.TextXAlignment.Left, Position = UDim2.fromOffset(58, 33), Size = UDim2.new(1, -62, 0, 14) }, Brand)

local NavList = new("Frame", { Position = UDim2.fromOffset(8, 70), Size = UDim2.new(1, -16, 1, -116), BackgroundTransparency = 1 }, Side)
new("UIListLayout", { Padding = UDim.new(0, 3), SortOrder = Enum.SortOrder.LayoutOrder }, NavList)

local footerLbl = new("TextLabel", {
	Text = "", Font = FONT, TextSize = 10, TextColor3 = T.dim, BackgroundTransparency = 1, TextXAlignment = Enum.TextXAlignment.Left,
	Position = UDim2.new(0, 16, 1, -36), Size = UDim2.new(1, -20, 0, 28),
}, Side)

-- main ------------------------------------------------------------------------
local Main = new("Frame", { Position = UDim2.fromOffset(SIDE_W, 0), Size = UDim2.new(1, -SIDE_W, 1, 0), BackgroundTransparency = 1 }, Win)
local TopBar = new("Frame", { Size = UDim2.new(1, 0, 0, 54), BackgroundTransparency = 1, Active = true }, Main)
local pageTitle = new("TextLabel", { Text = "", Font = FONTB, TextSize = 18, TextColor3 = T.text, BackgroundTransparency = 1, TextXAlignment = Enum.TextXAlignment.Left, Position = UDim2.fromOffset(18, 8), Size = UDim2.new(1, -110, 0, 22) }, TopBar)
local pageSub = new("TextLabel", { Text = "", Font = FONT, TextSize = 11, TextColor3 = T.sub, BackgroundTransparency = 1, TextXAlignment = Enum.TextXAlignment.Left, Position = UDim2.fromOffset(18, 30), Size = UDim2.new(1, -110, 0, 16) }, TopBar)

local function chipButton(text, xOff, color)
	local b = new("TextButton", { Text = text, Font = FONTB, TextSize = 15, TextColor3 = color or T.sub, BackgroundColor3 = T.cardHi, AutoButtonColor = false, Size = UDim2.fromOffset(30, 30), Position = UDim2.new(1, xOff, 0, 12), BorderSizePixel = 0 }, TopBar)
	corner(b, 9)
	return b
end
local btnMin = chipButton("-", -76)
local btnClose = chipButton("X", -40, T.bad)
makeDraggable(TopBar, Root, nil, clampRoot)
makeDraggable(Brand, Root, nil, clampRoot)

local Pages = new("Frame", { Position = UDim2.fromOffset(12, 56), Size = UDim2.new(1, -24, 1, -66), BackgroundTransparency = 1, ClipsDescendants = true }, Main)

-- notifications --------------------------------------------------------------
local NotifHolder = new("Frame", { AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -20, 0, 14), Size = UDim2.fromOffset(250, 300), BackgroundTransparency = 1, ZIndex = 80 }, Gui)
new("UIListLayout", { Padding = UDim.new(0, 6), SortOrder = Enum.SortOrder.LayoutOrder, HorizontalAlignment = Enum.HorizontalAlignment.Right }, NotifHolder)
local notifN = 0
local KIND_COLOR = { ok = T.good, info = nil, warn = T.warn, bad = T.bad }
local function notify(title, msg, kind, dur)
	if not S.ui.notify and kind ~= "bad" then return end
	notifN = notifN + 1
	local children = NotifHolder:GetChildren()
	local count = 0
	for _, ch in ipairs(children) do if ch:IsA("Frame") then count = count + 1 end end
	if count >= 4 then
		for _, ch in ipairs(children) do
			if ch:IsA("Frame") then ch:Destroy(); break end
		end
	end
	local slot = new("Frame", { Size = UDim2.new(1, 0, 0, 62), BackgroundTransparency = 1, LayoutOrder = notifN }, NotifHolder)
	local card = new("Frame", { Size = UDim2.new(1, 0, 1, 0), Position = UDim2.new(1, 60, 0, 0), BackgroundColor3 = T.card, BorderSizePixel = 0 }, slot)
	corner(card, 11)
	stroke(card, T.line, 1)
	local bar = new("Frame", { Size = UDim2.new(0, 3, 1, -16), Position = UDim2.new(0, 9, 0, 8), BackgroundColor3 = KIND_COLOR[kind or "info"] or A1, BorderSizePixel = 0 }, card)
	corner(bar, 2)
	new("TextLabel", { Text = title, Font = FONTB, TextSize = 12, TextColor3 = T.text, BackgroundTransparency = 1, TextXAlignment = Enum.TextXAlignment.Left, Position = UDim2.fromOffset(22, 6), Size = UDim2.new(1, -30, 0, 17), TextTruncate = Enum.TextTruncate.AtEnd }, card)
	new("TextLabel", { Text = msg or "", Font = FONT, TextSize = 11, TextColor3 = T.sub, BackgroundTransparency = 1, TextXAlignment = Enum.TextXAlignment.Left, Position = UDim2.fromOffset(22, 24), Size = UDim2.new(1, -30, 0, 32), TextWrapped = true, TextYAlignment = Enum.TextYAlignment.Top }, card)
	tween(card, 0.35, { Position = UDim2.new(0, 0, 0, 0) }, Enum.EasingStyle.Back)
	task.delay(dur or 2.4, function()
		if card.Parent then
			tween(card, 0.25, { Position = UDim2.new(1, 60, 0, 0) }, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
			task.wait(0.28)
			if slot.Parent then slot:Destroy() end
		end
	end)
end
local function say(name, v) notify(name, v and "Enabled" or "Disabled", v and "ok" or "info", 1.6) end

-- watermark + active list ----------------------------------------------------
local Mark = new("TextLabel", {
	Text = "", RichText = true, Font = FONTB, TextSize = 12, TextColor3 = T.sub, BackgroundColor3 = T.bg, BackgroundTransparency = 0.12, BorderSizePixel = 0,
	Position = UDim2.fromOffset(18, 14), Size = UDim2.fromOffset(0, 28), AutomaticSize = Enum.AutomaticSize.X, ZIndex = 60,
}, Gui)
corner(Mark, 9)
stroke(Mark, T.line, 1)
new("UIPadding", { PaddingLeft = UDim.new(0, 12), PaddingRight = UDim.new(0, 12) }, Mark)

local ActiveList = new("Frame", { Position = UDim2.fromOffset(18, 48), Size = UDim2.fromOffset(0, 0), AutomaticSize = Enum.AutomaticSize.XY, BackgroundTransparency = 1, ZIndex = 60 }, Gui)
new("UIListLayout", { Padding = UDim.new(0, 3), SortOrder = Enum.SortOrder.LayoutOrder }, ActiveList)
local activeKey = ""
local function refreshActive()
	local names, key = {}, ""
	for _, f in ipairs(FEATURES) do
		if f[2]() then names[#names + 1] = f[1]; key = key .. f[1] .. "|" end
	end
	if not S.ui.active then names, key = {}, "off" end
	if key == activeKey then return end
	activeKey = key
	for _, ch in ipairs(ActiveList:GetChildren()) do
		if ch:IsA("TextLabel") then ch:Destroy() end
	end
	for i, n in ipairs(names) do
		local l = new("TextLabel", {
			Text = n, Font = FONTB, TextSize = 11, TextColor3 = T.text, BackgroundColor3 = T.bg, BackgroundTransparency = 0.15, BorderSizePixel = 0,
			Size = UDim2.fromOffset(0, 20), AutomaticSize = Enum.AutomaticSize.X, LayoutOrder = i, ZIndex = 60,
		}, ActiveList)
		corner(l, 6)
		new("UIPadding", { PaddingLeft = UDim.new(0, 10), PaddingRight = UDim.new(0, 8) }, l)
		local b = new("Frame", { Size = UDim2.new(0, 2, 1, -8), Position = UDim2.new(0, -6, 0, 4), BackgroundColor3 = A1, BorderSizePixel = 0 }, l)
		corner(b, 1)
	end
end

-- tabs ------------------------------------------------------------------------
local tabs, activeTab = {}, nil
local function unlockScroll()
	for _, x in ipairs(tabs) do x.page.ScrollingEnabled = true end
end
local function selectTab(t)
	if activeTab == t then return end
	unlockScroll()
	for _, x in ipairs(tabs) do
		local on = x == t
		x.page.Visible = on
		tween(x.btn, 0.18, { BackgroundTransparency = on and 0 or 1 })
		tween(x.ind, 0.18, { BackgroundTransparency = on and 0 or 1 })
		tween(x.lbl, 0.18, { TextColor3 = on and T.text or T.sub })
		tween(x.chipFill, 0.18, { BackgroundTransparency = on and 0 or 1 })
	end
	t.page.Position = UDim2.fromOffset(0, 14)
	tween(t.page, 0.28, { Position = UDim2.fromOffset(0, 0) }, Enum.EasingStyle.Quint)
	pageTitle.Text = t.title
	pageSub.Text = t.sub
	activeTab = t
end

local function newTab(name, glyph, title, sub)
	local btn = new("TextButton", { Text = "", AutoButtonColor = false, Size = UDim2.new(1, 0, 0, 34), BackgroundColor3 = T.cardHi, BackgroundTransparency = 1, BorderSizePixel = 0, LayoutOrder = #tabs + 1 }, NavList)
	corner(btn, 9)
	local ind = new("Frame", { Size = UDim2.fromOffset(3, 16), Position = UDim2.new(0, 0, 0.5, -8), BackgroundColor3 = WHITE, BackgroundTransparency = 1, BorderSizePixel = 0 }, btn)
	corner(ind, 2)
	gradient(ind, 90)
	local chip = new("Frame", { Size = UDim2.fromOffset(22, 22), Position = UDim2.new(0, 10, 0.5, -11), BackgroundColor3 = T.line, BorderSizePixel = 0 }, btn)
	corner(chip, 7)
	local chipFill = new("Frame", { Size = UDim2.new(1, 0, 1, 0), BackgroundColor3 = WHITE, BackgroundTransparency = 1, BorderSizePixel = 0 }, chip)
	corner(chipFill, 7)
	gradient(chipFill, 45)
	new("TextLabel", { Text = glyph, Font = FONTB, TextSize = 11, TextColor3 = WHITE, BackgroundTransparency = 1, Size = UDim2.new(1, 0, 1, 0), ZIndex = 2 }, chip)
	local lbl = new("TextLabel", { Text = name, Font = FONTB, TextSize = 13, TextColor3 = T.sub, BackgroundTransparency = 1, TextXAlignment = Enum.TextXAlignment.Left, Position = UDim2.fromOffset(40, 0), Size = UDim2.new(1, -44, 1, 0) }, btn)
	local page = new("ScrollingFrame", {
		Size = UDim2.new(1, 0, 1, 0), BackgroundTransparency = 1, BorderSizePixel = 0, ScrollBarThickness = 3, ScrollBarImageColor3 = T.line,
		CanvasSize = UDim2.new(), AutomaticCanvasSize = Enum.AutomaticSize.Y, ScrollingDirection = Enum.ScrollingDirection.Y, Visible = false,
	}, Pages)
	new("UIListLayout", { Padding = UDim.new(0, 10), SortOrder = Enum.SortOrder.LayoutOrder }, page)
	new("UIPadding", { PaddingBottom = UDim.new(0, 12), PaddingRight = UDim.new(0, 8) }, page)
	local t = { btn = btn, ind = ind, lbl = lbl, chipFill = chipFill, page = page, n = 0, title = title, sub = sub }
	tabs[#tabs + 1] = t
	keep(btn.MouseButton1Click:Connect(function() selectTab(t) end))
	return t
end

-- cards + controls ------------------------------------------------------------
local function Card(t, title)
	t.n = t.n + 1
	local f = new("Frame", { Size = UDim2.new(1, 0, 0, 0), AutomaticSize = Enum.AutomaticSize.Y, BackgroundColor3 = T.card, BorderSizePixel = 0, LayoutOrder = t.n }, t.page)
	corner(f, 13)
	stroke(f, T.line, 1, 0.2)
	new("UIListLayout", { SortOrder = Enum.SortOrder.LayoutOrder }, f)
	local head = new("Frame", { Size = UDim2.new(1, 0, 0, 34), BackgroundTransparency = 1, LayoutOrder = 1 }, f)
	local dot = new("Frame", { Size = UDim2.fromOffset(3, 12), Position = UDim2.fromOffset(13, 12), BackgroundColor3 = WHITE, BorderSizePixel = 0 }, head)
	corner(dot, 2)
	gradient(dot, 90)
	new("TextLabel", { Text = string.upper(title), Font = FONTB, TextSize = 11, TextColor3 = T.sub, BackgroundTransparency = 1, TextXAlignment = Enum.TextXAlignment.Left, Position = UDim2.fromOffset(25, 0), Size = UDim2.new(1, -36, 1, 0) }, head)
	return { frame = f, n = 1, rows = 0, page = t.page }
end

local function add(g, inst)
	g.n = g.n + 1
	inst.LayoutOrder = g.n
	inst.Parent = g.frame
	return inst
end

local function row(g, h)
	g.rows = g.rows + 1
	local r = add(g, new("Frame", { Size = UDim2.new(1, 0, 0, h), BackgroundColor3 = T.cardHi, BackgroundTransparency = 1, BorderSizePixel = 0 }))
	if g.rows > 1 then
		new("Frame", { Size = UDim2.new(1, -26, 0, 1), Position = UDim2.fromOffset(13, 0), BackgroundColor3 = T.line, BackgroundTransparency = 0.45, BorderSizePixel = 0 }, r)
	end
	return r
end

local function rowLabel(r, text, desc)
	new("TextLabel", {
		Text = text, Font = FONTB, TextSize = 13, TextColor3 = T.text, BackgroundTransparency = 1, TextXAlignment = Enum.TextXAlignment.Left,
		Position = UDim2.fromOffset(13, desc and 7 or 0), Size = UDim2.new(1, -90, 0, desc and 20 or 42), TextTruncate = Enum.TextTruncate.AtEnd,
	}, r)
	if desc then
		new("TextLabel", { Text = desc, Font = FONT, TextSize = 10, TextColor3 = T.dim, BackgroundTransparency = 1, TextXAlignment = Enum.TextXAlignment.Left, Position = UDim2.fromOffset(13, 26), Size = UDim2.new(1, -90, 0, 16), TextTruncate = Enum.TextTruncate.AtEnd }, r)
	end
end

local function pressTint(r, hit)
	keep(hit.MouseButton1Down:Connect(function() tween(r, 0.08, { BackgroundTransparency = 0.6 }) end))
	keep(hit.MouseButton1Up:Connect(function() tween(r, 0.2, { BackgroundTransparency = 1 }) end))
	keep(hit.MouseLeave:Connect(function() tween(r, 0.2, { BackgroundTransparency = 1 }) end))
end

local function Toggle(g, text, init, cb, desc)
	local r = row(g, desc and 52 or 44)
	rowLabel(r, text, desc)
	local sw = new("Frame", { Size = UDim2.fromOffset(44, 24), Position = UDim2.new(1, -57, 0.5, -12), BackgroundColor3 = T.line, BorderSizePixel = 0 }, r)
	corner(sw, 12)
	local fillOn = new("Frame", { Size = UDim2.new(1, 0, 1, 0), BackgroundColor3 = WHITE, BackgroundTransparency = 1, BorderSizePixel = 0 }, sw)
	corner(fillOn, 12)
	gradient(fillOn, 0)
	local knob = new("Frame", { Size = UDim2.fromOffset(18, 18), Position = UDim2.fromOffset(3, 3), BackgroundColor3 = WHITE, BorderSizePixel = 0, ZIndex = 3 }, sw)
	corner(knob, 9)
	local state = init and true or false
	local function render(anim)
		local fo = state and 0 or 1
		local kp = state and UDim2.fromOffset(23, 3) or UDim2.fromOffset(3, 3)
		if anim then
			tween(fillOn, 0.2, { BackgroundTransparency = fo })
			tween(knob, 0.25, { Position = kp }, Enum.EasingStyle.Back)
		else
			fillOn.BackgroundTransparency = fo
			knob.Position = kp
		end
	end
	render(false)
	local hit = new("TextButton", { Text = "", BackgroundTransparency = 1, Size = UDim2.new(1, 0, 1, 0), ZIndex = 5 }, r)
	pressTint(r, hit)
	keep(hit.MouseButton1Click:Connect(function()
		state = not state
		render(true)
		cb(state)
	end))
end

local function Slider(g, text, min, max, step, init, cb, unit)
	local r = row(g, 58)
	new("TextLabel", { Text = text, Font = FONTB, TextSize = 13, TextColor3 = T.text, BackgroundTransparency = 1, TextXAlignment = Enum.TextXAlignment.Left, Position = UDim2.fromOffset(13, 8), Size = UDim2.new(1, -100, 0, 20) }, r)
	local chip = new("Frame", { Size = UDim2.fromOffset(70, 22), Position = UDim2.new(1, -83, 0, 8), BackgroundColor3 = T.cardHi, BorderSizePixel = 0 }, r)
	corner(chip, 7)
	local val = new("TextLabel", { Font = FONTB, TextSize = 12, TextColor3 = A1, BackgroundTransparency = 1, Size = UDim2.new(1, 0, 1, 0) }, chip)
	onAccent(function(a) val.TextColor3 = a end)
	local track = new("Frame", { Position = UDim2.new(0, 13, 1, -17), Size = UDim2.new(1, -26, 0, 6), BackgroundColor3 = T.line, BorderSizePixel = 0 }, r)
	corner(track, 3)
	local fill = new("Frame", { Size = UDim2.new(0, 0, 1, 0), BackgroundColor3 = WHITE, BorderSizePixel = 0 }, track)
	corner(fill, 3)
	gradient(fill, 0)
	local knob = new("Frame", { AnchorPoint = Vector2.new(0.5, 0.5), Size = UDim2.fromOffset(16, 16), Position = UDim2.new(0, 0, 0.5, 0), BackgroundColor3 = WHITE, BorderSizePixel = 0, ZIndex = 3 }, track)
	corner(knob, 8)
	local hit = new("TextButton", { Text = "", BackgroundTransparency = 1, Position = UDim2.new(0, 0, 0, 26), Size = UDim2.new(1, 0, 0, 32), ZIndex = 5 }, r)
	local fmt = step < 1 and "%.2f" or "%.0f"
	local cur = init
	local function render()
		local a = (cur - min) / (max - min)
		fill.Size = UDim2.new(a, 0, 1, 0)
		knob.Position = UDim2.new(a, 0, 0.5, 0)
		val.Text = string.format(fmt, cur) .. (unit or "")
	end
	local dragging = false
	local function endDrag()
		if dragging then
			dragging = false
			g.page.ScrollingEnabled = true
			tween(knob, 0.15, { Size = UDim2.fromOffset(16, 16) })
		end
	end
	local function apply(x)
		local a = clamp((x - track.AbsolutePosition.X) / math.max(track.AbsoluteSize.X, 1), 0, 1)
		local v = clamp(math.floor((min + (max - min) * a) / step + 0.5) * step, min, max)
		if v ~= cur then
			cur = v
			render()
			cb(v)
		end
	end
	keep(hit.InputBegan:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
			dragging = true
			g.page.ScrollingEnabled = false
			tween(knob, 0.12, { Size = UDim2.fromOffset(21, 21) })
			apply(input.Position.X)
		end
	end))
	keep(UserInputService.InputChanged:Connect(function(input)
		if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
			if input.UserInputState == Enum.UserInputState.End or input.UserInputState == Enum.UserInputState.Cancel then endDrag() else apply(input.Position.X) end
		end
	end))
	keep(UserInputService.InputEnded:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then endDrag() end
	end))
	render()
end

local function Cycle(g, text, options, idx, cb)
	local r = row(g, 44)
	rowLabel(r, text)
	local chip = new("Frame", { Size = UDim2.fromOffset(122, 26), Position = UDim2.new(1, -135, 0.5, -13), BackgroundColor3 = T.cardHi, BorderSizePixel = 0 }, r)
	corner(chip, 8)
	local v = new("TextLabel", { Text = tostring(options[idx]), Font = FONTB, TextSize = 12, TextColor3 = A1, BackgroundTransparency = 1, Size = UDim2.new(1, -24, 1, 0), Position = UDim2.fromOffset(12, 0), TextTruncate = Enum.TextTruncate.AtEnd }, chip)
	onAccent(function(a) v.TextColor3 = a end)
	new("TextLabel", { Text = ">", Font = FONTB, TextSize = 12, TextColor3 = T.dim, BackgroundTransparency = 1, Size = UDim2.fromOffset(14, 26), Position = UDim2.new(1, -16, 0, 0) }, chip)
	local hit = new("TextButton", { Text = "", BackgroundTransparency = 1, Size = UDim2.new(1, 0, 1, 0), ZIndex = 5 }, r)
	pressTint(r, hit)
	keep(hit.MouseButton1Click:Connect(function()
		idx = idx % #options + 1
		v.Text = tostring(options[idx])
		cb(options[idx], idx)
	end))
end

local function Button(g, text, cb, kind)
	local r = row(g, 48)
	local b = new("TextButton", {
		Text = text, Font = FONTB, TextSize = 13, TextColor3 = WHITE, AutoButtonColor = false, BorderSizePixel = 0,
		Size = UDim2.new(1, -26, 0, 34), Position = UDim2.fromOffset(13, 7), BackgroundColor3 = WHITE,
	}, r)
	corner(b, 10)
	local sc = new("UIScale", { Scale = 1 }, b)
	if kind == "danger" then
		b.BackgroundColor3 = Color3.fromRGB(190, 56, 78)
	elseif kind == "ghost" then
		b.BackgroundColor3 = T.cardHi
		b.TextColor3 = T.text
		stroke(b, T.line, 1)
	else
		gradient(b, 0)
	end
	keep(b.MouseButton1Down:Connect(function() tween(sc, 0.08, { Scale = 0.96 }) end))
	keep(b.MouseButton1Up:Connect(function() tween(sc, 0.18, { Scale = 1 }, Enum.EasingStyle.Back) end))
	keep(b.MouseLeave:Connect(function() tween(sc, 0.15, { Scale = 1 }) end))
	keep(b.MouseButton1Click:Connect(function() cb(b) end))
	return b
end

local function Input(g, placeholder, cb)
	local r = row(g, 48)
	local box = new("Frame", { Size = UDim2.new(1, -26, 0, 32), Position = UDim2.fromOffset(13, 8), BackgroundColor3 = T.cardHi, BorderSizePixel = 0 }, r)
	corner(box, 9)
	stroke(box, T.line, 1)
	local tb = new("TextBox", {
		PlaceholderText = placeholder, PlaceholderColor3 = T.dim, Text = "", ClearTextOnFocus = false, Font = FONT, TextSize = 12,
		TextColor3 = T.text, BackgroundTransparency = 1, Size = UDim2.new(1, -20, 1, 0), Position = UDim2.fromOffset(10, 0), TextXAlignment = Enum.TextXAlignment.Left,
	}, box)
	keep(tb.FocusLost:Connect(function() cb(tb.Text) end))
end

local function Note(g, text)
	local r = add(g, new("Frame", { Size = UDim2.new(1, 0, 0, 0), AutomaticSize = Enum.AutomaticSize.Y, BackgroundTransparency = 1, BorderSizePixel = 0 }))
	new("UIPadding", { PaddingBottom = UDim.new(0, 10), PaddingTop = UDim.new(0, 2) }, r)
	return new("TextLabel", {
		Text = text, Font = FONT, TextSize = 11, TextColor3 = T.sub, BackgroundTransparency = 1, TextWrapped = true,
		Size = UDim2.new(1, -26, 0, 0), Position = UDim2.fromOffset(13, 0), AutomaticSize = Enum.AutomaticSize.Y,
		TextXAlignment = Enum.TextXAlignment.Left, TextYAlignment = Enum.TextYAlignment.Top,
	}, r)
end

-- log pane --------------------------------------------------------------------
local logLines, logDirty, logLabel, logFrame = {}, false, nil, nil
local function log(msg)
	logLines[#logLines + 1] = tostring(msg)
	if #logLines > 160 then table.remove(logLines, 1) end
	logDirty = true
end
local function flushLog()
	if logDirty and logLabel then
		logDirty = false
		logLabel.Text = table.concat(logLines, "\n")
		task.defer(function()
			if logFrame and logFrame.Parent then logFrame.CanvasPosition = Vector2.new(0, logFrame.AbsoluteCanvasSize.Y) end
		end)
	end
end
local function LogPane(g, height)
	local wrap = add(g, new("Frame", { Size = UDim2.new(1, 0, 0, height + 14), BackgroundTransparency = 1 }))
	logFrame = new("ScrollingFrame", {
		Size = UDim2.new(1, -26, 0, height), Position = UDim2.fromOffset(13, 2), BackgroundColor3 = Color3.fromRGB(9, 10, 14), BorderSizePixel = 0,
		ScrollBarThickness = 3, ScrollBarImageColor3 = T.line, CanvasSize = UDim2.new(), AutomaticCanvasSize = Enum.AutomaticSize.Y, ScrollingDirection = Enum.ScrollingDirection.Y,
	}, wrap)
	corner(logFrame, 9)
	new("UIPadding", { PaddingLeft = UDim.new(0, 8), PaddingTop = UDim.new(0, 6), PaddingRight = UDim.new(0, 6), PaddingBottom = UDim.new(0, 6) }, logFrame)
	logLabel = new("TextLabel", {
		Text = "", Font = Enum.Font.Code, TextSize = 11, TextColor3 = T.sub, BackgroundTransparency = 1, TextWrapped = true,
		Size = UDim2.new(1, 0, 0, 0), AutomaticSize = Enum.AutomaticSize.Y, TextXAlignment = Enum.TextXAlignment.Left, TextYAlignment = Enum.TextYAlignment.Top,
	}, logFrame)
end

---------------------------------------------------------------------
-- combat logic
---------------------------------------------------------------------
local aimTarget = nil

local function pickAimTarget(c, vp)
	local center = Vector2.new(vp.X / 2, vp.Y / 2)
	local best, bestD, bestPos
	for _, t in ipairs(listTargets(S.aim.plrs, S.aim.bots)) do
		local part = aimPart(t, S.aim.part)
		local sp, on = c:WorldToViewportPoint(part.Position)
		if on then
			local d = (Vector2.new(sp.X, sp.Y) - center).Magnitude
			if d <= S.aim.fov and (not bestD or d < bestD) then
				if not S.aim.wall or visible(c, t, part) then
					best, bestD, bestPos = t, d, part.Position
				end
			end
		end
	end
	return best, bestPos
end

local HIT_SIGNALS = { "MouseButton1Down", "MouseButton1Up", "MouseButton1Click", "Activated", "TouchTap" }
local INPUT_SIGNALS = { "InputBegan", "InputEnded" }
local function hitButton()
	local pg = LP:FindFirstChild("PlayerGui")
	local g = pg and pg:FindFirstChild("MCTouch")
	return g and g:FindFirstChild("Hit")
end

-- synthetic touch for games that read InputBegan / InputEnded on the button itself
local function fakeInput(pos)
	local f = {
		UserInputType = Enum.UserInputType.Touch, UserInputState = Enum.UserInputState.Begin,
		Position = Vector3.new(pos.X, pos.Y, 0), Delta = Vector3.zero, KeyCode = Enum.KeyCode.Unknown,
	}
	local cbs = {}
	f.Changed = { Connect = function(_, fn) cbs[#cbs + 1] = fn; return { Disconnect = function() end } end }
	f.finish = function()
		f.UserInputState = Enum.UserInputState.End
		for _, fn in ipairs(cbs) do pcall(fn, "UserInputState") end
	end
	return f
end
local function fireConn(c, ...)
	if c.Fire then c:Fire(...) elseif c.Function then c.Function(...) end
end

local warnedHit = false
local function pressHit()
	local btn = hitButton()
	if not btn then return false end
	local fired = 0
	for _, name in ipairs(HIT_SIGNALS) do
		local ok, list = pcall(getconnections, btn[name])
		if ok and type(list) == "table" and #list > 0 then
			if pcall(firesignal, btn[name]) then fired = fired + 1 end
		end
	end
	if fired == 0 then
		local okB, began = pcall(getconnections, btn.InputBegan)
		local okE, ended = pcall(getconnections, btn.InputEnded)
		local nB = (okB and type(began) == "table") and #began or 0
		local nE = (okE and type(ended) == "table") and #ended or 0
		if nB + nE > 0 then
			fired = 1
			local pos = btn.AbsolutePosition + btn.AbsoluteSize / 2
			task.spawn(function()
				local fi = fakeInput(pos)
				if nB > 0 then for _, c in ipairs(began) do pcall(fireConn, c, fi) end end
				task.wait(0.03)
				fi.finish()
				if nE > 0 then for _, c in ipairs(ended) do pcall(fireConn, c, fi) end end
			end)
		end
	end
	if fired == 0 then
		-- touch fallback only while the hub is hidden, so it can never click the hub itself
		if VirtualInputManager and not hubOpen then
			local p = btn.AbsolutePosition + btn.AbsoluteSize / 2
			pcall(function()
				VirtualInputManager:SendMouseButtonEvent(p.X, p.Y, 0, true, game, 0)
				VirtualInputManager:SendMouseButtonEvent(p.X, p.Y, 0, false, game, 0)
			end)
		elseif not warnedHit then
			warnedHit = true
			notify("Auto hit", "The HIT button has no hooks I can fire. Tap the L bubble to hide the hub so the touch fallback can run, or open Probe and run Test HIT.", "warn", 6)
		end
	end
	return fired > 0
end

local lastHit = 0
local function stepTrigger()
	if not S.trig.on then return end
	local now = os.clock()
	if now - lastHit < S.trig.delay then return end
	local root, c = myRoot(), cam()
	if not root or not c then return end
	local vp = c.ViewportSize
	local center = Vector2.new(vp.X / 2, vp.Y / 2)
	for _, t in ipairs(listTargets(S.aim.plrs, S.aim.bots)) do
		if (t.root.Position - root.Position).Magnitude <= S.trig.reach then
			local part = aimPart(t, S.aim.part)
			local sp, on = c:WorldToViewportPoint(part.Position)
			if on and (Vector2.new(sp.X, sp.Y) - center).Magnitude <= S.trig.radius and (not S.aim.wall or visible(c, t, part)) then
				lastHit = now
				pressHit()
				return
			end
		end
	end
end

-- hitbox expander
local hbOrig = {}
local function hbRestoreOne(part)
	local o = hbOrig[part]
	if o and part.Parent then pcall(function() part.Size = o.size; part.CanCollide = o.cc end) end
	hbOrig[part] = nil
end
local function hbRestore()
	for part in pairs(hbOrig) do hbRestoreOne(part) end
end
local function stepHitbox()
	if not S.hit.on then
		if next(hbOrig) then hbRestore() end
		return
	end
	local seen = {}
	for _, t in ipairs(listTargets(true, true)) do
		local p = t.model:FindFirstChild(S.hit.part)
		if p and p:IsA("BasePart") then
			if not hbOrig[p] then hbOrig[p] = { size = p.Size, cc = p.CanCollide } end
			p.Size = Vector3.new(S.hit.size, S.hit.size, S.hit.size)
			p.CanCollide = false
			seen[p] = true
		end
	end
	for part in pairs(hbOrig) do
		if not seen[part] then hbRestoreOne(part) end
	end
end

---------------------------------------------------------------------
-- ESP
---------------------------------------------------------------------
local espRoot = new("Folder", { Name = "LunyxESP" })
espRoot.Parent = host
local espObjs = {}
local CHAM_LIMIT = 8

local function createEsp(t)
	local o = { t = t, txt = "" }
	o.box = new("BillboardGui", { Name = "Box", AlwaysOnTop = true, Size = UDim2.new(4, 0, 6, 0), Adornee = t.root, LightInfluence = 0, ResetOnSpawn = false }, espRoot)
	o.outline = new("Frame", { Size = UDim2.new(1, 0, 1, 0), BackgroundTransparency = 1, BorderSizePixel = 0 }, o.box)
	o.stroke = new("UIStroke", { Thickness = 1.5, ApplyStrokeMode = Enum.ApplyStrokeMode.Border }, o.outline)
	o.barBg = new("Frame", { Position = UDim2.new(-0.1, 0, 0, 0), Size = UDim2.new(0.05, 0, 1, 0), BackgroundColor3 = Color3.new(0, 0, 0), BackgroundTransparency = 0.4, BorderSizePixel = 0 }, o.box)
	o.bar = new("Frame", { AnchorPoint = Vector2.new(0, 1), Position = UDim2.new(0, 0, 1, 0), Size = UDim2.new(1, 0, 1, 0), BackgroundColor3 = T.good, BorderSizePixel = 0 }, o.barBg)
	o.tag = new("BillboardGui", { Name = "Tag", AlwaysOnTop = true, Size = UDim2.fromOffset(200, 34), StudsOffset = Vector3.new(0, 3.9, 0), Adornee = t.root, LightInfluence = 0, ResetOnSpawn = false }, espRoot)
	o.label = new("TextLabel", { Size = UDim2.new(1, 0, 1, 0), BackgroundTransparency = 1, Font = FONTB, TextSize = 13, TextColor3 = T.text, TextStrokeTransparency = 0.4, Text = "" }, o.tag)
	o.line = new("Frame", { AnchorPoint = Vector2.new(0.5, 0.5), BorderSizePixel = 0, Visible = false, BackgroundColor3 = T.text }, overlay)
	return o
end

local function destroyEsp(o)
	for _, k in ipairs({ "box", "tag", "line", "hl" }) do
		if o[k] then pcall(function() o[k]:Destroy() end) end
	end
end

local function stepEsp(c, vp)
	local cur = {}
	if S.esp.on then
		for _, t in ipairs(listTargets(S.esp.plrs, S.esp.bots)) do cur[t.model] = t end
	end
	for m, o in pairs(espObjs) do
		if not cur[m] then destroyEsp(o); espObjs[m] = nil end
	end
	local camPos = c.CFrame.Position
	local dists, order = {}, {}
	for m, t in pairs(cur) do
		dists[m] = (camPos - t.root.Position).Magnitude
		order[#order + 1] = m
	end
	local chamOk = {}
	if S.esp.chams then
		table.sort(order, function(a, b) return dists[a] < dists[b] end)
		for i = 1, math.min(CHAM_LIMIT, #order) do chamOk[order[i]] = true end
	end
	local origin = Vector2.new(vp.X / 2, vp.Y)
	for m, t in pairs(cur) do
		local o = espObjs[m]
		if not o then o = createEsp(t); espObjs[m] = o end
		o.t = t
		local col = t.bot and BOT_COLOR or PALETTE[S.esp.color][2]
		local dist = dists[m]
		local show = dist <= S.esp.maxd
		o.box.Enabled = show and (S.esp.box or S.esp.hp)
		o.outline.Visible = S.esp.box
		o.barBg.Visible = S.esp.hp
		o.stroke.Color = col
		local mh = math.max(t.hum.MaxHealth, 1)
		local pct = clamp(t.hum.Health / mh, 0, 1)
		o.bar.Size = UDim2.new(1, 0, pct, 0)
		o.bar.BackgroundColor3 = T.bad:Lerp(T.good, pct)
		local parts = {}
		if S.esp.name then parts[#parts + 1] = t.name end
		if S.esp.hp then parts[#parts + 1] = string.format("%d/%d", math.floor(t.hum.Health + 0.5), math.floor(mh + 0.5)) end
		if S.esp.dist then parts[#parts + 1] = string.format("%dst", math.floor(dist + 0.5)) end
		local txt = table.concat(parts, "  |  ")
		if txt ~= o.txt then o.txt = txt; o.label.Text = txt end
		o.label.TextColor3 = col
		o.tag.Enabled = show and #parts > 0
		local drawLine = false
		if S.esp.tracer and show then
			local sp, on = c:WorldToViewportPoint(t.root.Position)
			if on then
				local b = Vector2.new(sp.X, sp.Y)
				local d = b - origin
				o.line.Position = UDim2.fromOffset((origin.X + b.X) / 2, (origin.Y + b.Y) / 2)
				o.line.Size = UDim2.fromOffset(d.Magnitude, 1.5)
				o.line.Rotation = math.deg(math.atan2(d.Y, d.X))
				o.line.BackgroundColor3 = col
				drawLine = true
			end
		end
		o.line.Visible = drawLine
		if S.esp.chams and show and chamOk[m] then
			if not o.hl then
				o.hl = new("Highlight", { Adornee = t.model, FillTransparency = 0.65, OutlineTransparency = 0, DepthMode = Enum.HighlightDepthMode.AlwaysOnTop }, espRoot)
			end
			o.hl.FillColor = col
			o.hl.OutlineColor = col
			o.hl.Enabled = true
		elseif o.hl then
			o.hl.Enabled = false
		end
	end
end

---------------------------------------------------------------------
-- visuals (lighting, fov)
---------------------------------------------------------------------
local fullOrig, fogOrig, fxOrig, fovOrig
local function setFull(on)
	if on then
		if not fullOrig then
			fullOrig = { Brightness = Lighting.Brightness, ClockTime = Lighting.ClockTime, GlobalShadows = Lighting.GlobalShadows, Ambient = Lighting.Ambient, OutdoorAmbient = Lighting.OutdoorAmbient }
		end
	elseif fullOrig then
		for k, v in pairs(fullOrig) do pcall(function() Lighting[k] = v end) end
		fullOrig = nil
	end
end
local function setFog(on)
	if on then
		if not fogOrig then
			local atmo = Lighting:FindFirstChildOfClass("Atmosphere")
			fogOrig = { FogEnd = Lighting.FogEnd, FogStart = Lighting.FogStart, atmo = atmo, Density = atmo and atmo.Density, Haze = atmo and atmo.Haze }
		end
	elseif fogOrig then
		pcall(function() Lighting.FogEnd = fogOrig.FogEnd; Lighting.FogStart = fogOrig.FogStart end)
		if fogOrig.atmo and fogOrig.Density then
			pcall(function() fogOrig.atmo.Density = fogOrig.Density; fogOrig.atmo.Haze = fogOrig.Haze end)
		end
		fogOrig = nil
	end
end
local function setClean(on)
	if on then
		if not fxOrig then
			fxOrig = {}
			for _, e in ipairs(Lighting:GetChildren()) do
				if e:IsA("PostEffect") then fxOrig[e] = e.Enabled end
			end
		end
	elseif fxOrig then
		for e, en in pairs(fxOrig) do pcall(function() e.Enabled = en end) end
		fxOrig = nil
	end
end
local function setFov(on)
	local c = cam()
	if on then
		if c and not fovOrig then fovOrig = c.FieldOfView end
	elseif fovOrig then
		if c then pcall(function() c.FieldOfView = fovOrig end) end
		fovOrig = nil
	end
end
local function stepLighting()
	if fullOrig then
		Lighting.Brightness = 2
		Lighting.ClockTime = 14
		Lighting.GlobalShadows = false
		Lighting.Ambient = Color3.fromRGB(180, 180, 180)
		Lighting.OutdoorAmbient = Color3.fromRGB(180, 180, 180)
	end
	if fogOrig then
		Lighting.FogEnd = 1e6
		if fogOrig.atmo then fogOrig.atmo.Density = 0; fogOrig.atmo.Haze = 0 end
	end
	if fxOrig then
		for e in pairs(fxOrig) do
			if e.Parent then e.Enabled = false end
		end
	end
end

---------------------------------------------------------------------
-- movement
---------------------------------------------------------------------
local humOrig
local function setHum(on)
	local hum = myHum()
	if on then
		if hum and not humOrig then humOrig = { WalkSpeed = hum.WalkSpeed, JumpPower = hum.JumpPower, UseJumpPower = hum.UseJumpPower } end
	elseif humOrig then
		if hum then pcall(function() for k, v in pairs(humOrig) do hum[k] = v end end) end
		humOrig = nil
	end
end

-- returns (right, forward) in -1..1, camera relative
local function moveInput()
	local c = cam()
	if not c then return 0, 0 end
	local look = c.CFrame.LookVector
	local flat = Vector3.new(look.X, 0, look.Z)
	if flat.Magnitude < 1e-3 then return 0, 0 end
	flat = flat.Unit
	local right = Vector3.new(-flat.Z, 0, flat.X)
	local hum = myHum()
	if hum and hum.MoveDirection.Magnitude > 0.05 then
		local md = hum.MoveDirection
		return md:Dot(right), md:Dot(flat)
	end
	local pg = LP:FindFirstChild("PlayerGui")
	local touch = pg and pg:FindFirstChild("MCTouch")
	local stick = touch and touch:FindFirstChild("StickBase")
	local knob = stick and stick:FindFirstChild("Knob")
	if stick and knob then
		local rad = stick.AbsoluteSize.X / 2
		local off = (knob.AbsolutePosition + knob.AbsoluteSize / 2) - (stick.AbsolutePosition + stick.AbsoluteSize / 2)
		if rad > 0 and off.Magnitude > rad * 0.15 then
			local v = off / rad
			if v.Magnitude > 1 then v = v.Unit end
			return v.X, -v.Y
		end
	end
	return 0, 0
end

local function stepMovement(dt)
	local root, hum, c = myRoot(), myHum(), cam()
	if not root or not c then return end
	if S.mov.hum and hum then
		if not humOrig then setHum(true) end
		hum.WalkSpeed = S.mov.ws
		hum.UseJumpPower = true
		hum.JumpPower = S.mov.jp
	end
	if S.mov.fly then
		local r, f = moveInput()
		local v = c.CFrame.LookVector * f + c.CFrame.RightVector * r
		if v.Magnitude > 1 then v = v.Unit end
		root.AssemblyLinearVelocity = Vector3.zero
		if v.Magnitude > 0.02 then root.CFrame = root.CFrame + v * (S.mov.flyv * dt) end
	elseif S.mov.speed then
		local r, f = moveInput()
		local look = c.CFrame.LookVector
		local flat = Vector3.new(look.X, 0, look.Z)
		if flat.Magnitude > 1e-3 then
			flat = flat.Unit
			local right = Vector3.new(-flat.Z, 0, flat.X)
			local v = flat * f + right * r
			if v.Magnitude > 1 then v = v.Unit end
			if v.Magnitude > 0.02 then root.CFrame = root.CFrame + v * (S.mov.speedv * dt) end
		end
	end
end

local function hop()
	if not S.mov.ijump then return end
	local hum, root = myHum(), myRoot()
	if hum then pcall(function() hum:ChangeState(Enum.HumanoidStateType.Jumping) end) end
	if root then
		local v = root.AssemblyLinearVelocity
		root.AssemblyLinearVelocity = Vector3.new(v.X, 52, v.Z)
	end
end
keep(UserInputService.JumpRequest:Connect(hop))
do
	local pg = LP:FindFirstChild("PlayerGui")
	local touch = pg and pg:FindFirstChild("MCTouch")
	local jb = touch and touch:FindFirstChild("Jump")
	if jb then keep(jb.MouseButton1Down:Connect(hop)) end
end

---------------------------------------------------------------------
-- remote spy + module dump (Probe)
---------------------------------------------------------------------
local function ser(v, d)
	d = d or 0
	local t = typeof(v)
	if t == "string" then return string.format("%q", v)
	elseif t == "table" then
		if d > 2 then return "{...}" end
		local parts, n = {}, 0
		for k, x in pairs(v) do
			n = n + 1
			if n > 12 then parts[#parts + 1] = "..."; break end
			parts[#parts + 1] = "[" .. ser(k, d + 1) .. "]=" .. ser(x, d + 1)
		end
		return "{" .. table.concat(parts, ", ") .. "}"
	elseif t == "Instance" then
		local ok, n = pcall(function() return v:GetFullName() end)
		return ok and n or tostring(v)
	end
	return tostring(v)
end

local function installSpy()
	if env.__LUNYX_HOOKED then return true end
	if not (hookmetamethod and getnamecallmethod) then return false end
	local old
	local wrap = newcclosure or function(f) return f end
	old = hookmetamethod(game, "__namecall", wrap(function(self, ...)
		local method = getnamecallmethod()
		if method == "FireServer" or method == "InvokeServer" then
			local fn = env.__LUNYX_SPYFN
			if fn then fn(self, method, ...) end
		end
		if setnamecallmethod then setnamecallmethod(method) end
		return old(self, ...)
	end))
	env.__LUNYX_HOOKED = true
	return true
end

env.__LUNYX_SPYFN = function(remote, method, ...)
	if not alive or not S.probe.spy then return end
	local ok, parent = pcall(function() return remote.Parent end)
	if not ok or not parent or parent.Name ~= "MCRemotes" then return end
	local name = remote.Name
	if not S.probe.spam and (name == "Look" or name == "Sync") then return end
	if checkcaller and checkcaller() then return end
	local args = table.pack(...)
	local stamp = os.clock() % 1000
	task.defer(function()
		local strs = {}
		for i = 1, args.n do strs[i] = ser(args[i]) end
		log(string.format("[%.2f] %s:%s(%s)", stamp, name, method, table.concat(strs, ", ")))
	end)
end

local function resolveDump(label)
	local scope, name = label:match("^(%w+)%.(.+)$")
	if scope == "Pof" then
		local ps = LP:FindFirstChild("PlayerScripts")
		local base = ps and ps:FindFirstChild("PoFClient")
		return base and base:FindFirstChild(name)
	end
	local cur = ReplicatedStorage:FindFirstChild("Shared")
	if scope == "Config" then cur = cur and cur:FindFirstChild("Config") end
	for part in name:gmatch("[^%.]+") do cur = cur and cur:FindFirstChild(part) end
	return cur
end

local function dumpModule(label)
	local ms = resolveDump(label)
	if not ms then log("dump: " .. label .. " not found"); return end
	local ok, mod = pcall(require, ms)
	if not ok then log("dump: require failed: " .. tostring(mod)); return end
	log("== " .. label .. " (" .. type(mod) .. ")")
	if type(mod) ~= "table" then log(tostring(mod)); return end
	local list = {}
	for k, v in pairs(mod) do list[#list + 1] = { tostring(k), v } end
	table.sort(list, function(a, b) return a[1] < b[1] end)
	for i, kv in ipairs(list) do
		if i > 90 then log("... +" .. (#list - 90) .. " more"); break end
		local v, tv = kv[2], type(kv[2])
		local shown = tv
		if tv == "number" or tv == "boolean" or tv == "string" then
			shown = tv .. " = " .. tostring(v)
		elseif tv == "table" then
			local n = 0
			for _ in pairs(v) do n = n + 1 end
			shown = "table(" .. n .. ")"
		end
		log("  " .. kv[1] .. " : " .. shown)
	end
end

---------------------------------------------------------------------
-- config tweaker
---------------------------------------------------------------------
local CFG_MODULES = { "Physics", "Combat", "Projectiles", "Dev", "Experiments", "Presentation" }
local cfgFields = {}
local cfgName, cfgFilter = "Physics", ""
local cfgBox, cfgInfo
local cfgRender

local function cfgLoad(name)
	if cfgFields[name] then return cfgFields[name] end
	local shared = ReplicatedStorage:FindFirstChild("Shared")
	local folder = shared and shared:FindFirstChild("Config")
	local ms = folder and folder:FindFirstChild(name)
	if not ms or not ms:IsA("ModuleScript") then log("config: " .. name .. " not found"); return nil end
	local ok, mod = pcall(require, ms)
	if not ok or type(mod) ~= "table" then log("config: " .. name .. " require failed: " .. tostring(mod)); return nil end
	local out, seen = {}, { [mod] = true }
	local function walk(tbl, prefix, depth)
		for k, v in pairs(tbl) do
			local path = prefix == "" and tostring(k) or (prefix .. "." .. tostring(k))
			local tv = type(v)
			if tv == "number" or tv == "boolean" then
				out[#out + 1] = { path = path, parent = tbl, key = k, orig = v }
			elseif tv == "table" and depth < 3 and not seen[v] then
				seen[v] = true
				walk(v, path, depth + 1)
			end
		end
	end
	walk(mod, "", 0)
	table.sort(out, function(a, b) return a.path < b.path end)
	cfgFields[name] = out
	return out
end

local function cfgSet(parent, key, v)
	local ok = pcall(function() parent[key] = v end)
	if (not ok or rawget(parent, key) ~= v) and setreadonly then
		pcall(setreadonly, parent, false)
		ok = pcall(function() parent[key] = v end)
	end
	return ok and rawget(parent, key) == v
end

local function fmtNum(v)
	return tostring(math.floor(v * 1000 + 0.5) / 1000)
end

local function buildCfgRow(f, order)
	local r = new("Frame", { Size = UDim2.new(1, 0, 0, 36), BackgroundColor3 = T.cardHi, BackgroundTransparency = 1, BorderSizePixel = 0, LayoutOrder = order }, cfgBox)
	if order > 1 then
		new("Frame", { Size = UDim2.new(1, -26, 0, 1), Position = UDim2.fromOffset(13, 0), BackgroundColor3 = T.line, BackgroundTransparency = 0.45, BorderSizePixel = 0 }, r)
	end
	new("TextLabel", {
		Text = f.path, Font = FONT, TextSize = 11, TextColor3 = T.text, BackgroundTransparency = 1, TextXAlignment = Enum.TextXAlignment.Left,
		TextTruncate = Enum.TextTruncate.AtEnd, Position = UDim2.fromOffset(13, 0), Size = UDim2.new(1, -124, 1, 0),
	}, r)
	local function flash(good)
		r.BackgroundColor3 = good and Color3.fromRGB(34, 70, 52) or Color3.fromRGB(80, 34, 44)
		r.BackgroundTransparency = 0.2
		tween(r, 0.6, { BackgroundTransparency = 1 })
	end
	if type(f.orig) == "boolean" then
		local b = new("TextButton", { Text = tostring(f.parent[f.key]), Font = FONTB, TextSize = 12, TextColor3 = A1, BackgroundColor3 = T.cardHi, AutoButtonColor = false, Size = UDim2.fromOffset(92, 24), Position = UDim2.new(1, -105, 0.5, -12), BorderSizePixel = 0 }, r)
		corner(b, 8)
		keep(b.MouseButton1Click:Connect(function()
			local nv = not f.parent[f.key]
			if cfgSet(f.parent, f.key, nv) then b.Text = tostring(nv); flash(true) else flash(false) end
		end))
	else
		local tb = new("TextBox", { Text = fmtNum(f.parent[f.key]), ClearTextOnFocus = false, Font = FONTB, TextSize = 12, TextColor3 = A1, BackgroundColor3 = T.cardHi, Size = UDim2.fromOffset(92, 24), Position = UDim2.new(1, -105, 0.5, -12), BorderSizePixel = 0 }, r)
		corner(tb, 8)
		keep(tb.FocusLost:Connect(function()
			local n = tonumber(tb.Text)
			if n and cfgSet(f.parent, f.key, n) then flash(true) else flash(false); tb.Text = fmtNum(f.parent[f.key]) end
		end))
	end
end

cfgRender = function()
	for _, c in ipairs(cfgBox:GetChildren()) do
		if c:IsA("Frame") then c:Destroy() end
	end
	local fields = cfgLoad(cfgName)
	if not fields then cfgInfo.Text = cfgName .. ": could not load (see Probe log)"; return end
	local shown, matched = 0, 0
	for _, f in ipairs(fields) do
		if cfgFilter == "" or f.path:lower():find(cfgFilter, 1, true) then
			matched = matched + 1
			if shown < 70 then
				shown = shown + 1
				buildCfgRow(f, shown)
			end
		end
	end
	cfgInfo.Text = string.format("%s: %d values, showing %d. Edits are client-side only.", cfgName, #fields, shown)
	if matched > shown then cfgInfo.Text = cfgInfo.Text .. " Narrow the filter for the rest." end
end

---------------------------------------------------------------------
-- build tabs
---------------------------------------------------------------------
local Destroy -- forward

local TC = newTab("Combat", "C", "Combat", "Aim assist, auto hit and hitboxes")
do
	local g = Card(TC, "Aim assist")
	Toggle(g, "Aim assist", S.aim.on, function(v) S.aim.on = v; say("Aim assist", v) end, "Pulls the camera onto the nearest target")
	Slider(g, "Aim FOV", 30, 500, 5, S.aim.fov, function(v) S.aim.fov = v end, "px")
	Slider(g, "Smoothing", 0.05, 1, 0.05, S.aim.smooth, function(v) S.aim.smooth = v end)
	Cycle(g, "Aim part", { "Head", "Torso", "HumanoidRootPart" }, 1, function(v) S.aim.part = v end)
	Toggle(g, "Wall check", S.aim.wall, function(v) S.aim.wall = v end, "Ignore targets behind blocks")
	Toggle(g, "Target players", S.aim.plrs, function(v) S.aim.plrs = v end)
	Toggle(g, "Target bots", S.aim.bots, function(v) S.aim.bots = v end)
	Toggle(g, "FOV circle", S.aim.circle, function(v) S.aim.circle = v end)

	local g2 = Card(TC, "Auto hit")
	Toggle(g2, "Auto hit", S.trig.on, function(v) S.trig.on = v; say("Auto hit", v) end, "Taps HIT when a target is under the crosshair")
	Slider(g2, "Reach", 3, 40, 1, S.trig.reach, function(v) S.trig.reach = v end, " st")
	Slider(g2, "Crosshair radius", 10, 250, 5, S.trig.radius, function(v) S.trig.radius = v end, "px")
	Slider(g2, "Delay", 0.05, 1, 0.01, S.trig.delay, function(v) S.trig.delay = v end, "s")

	local g3 = Card(TC, "Hitbox")
	Toggle(g3, "Hitbox expander", S.hit.on, function(v) S.hit.on = v; if not v then hbRestore() end; say("Hitbox expander", v) end, "Grows enemy hit parts on your client")
	Slider(g3, "Size", 2, 24, 1, S.hit.size, function(v) S.hit.size = v end, " st")
	Cycle(g3, "Part", { "HumanoidRootPart", "Head", "Torso" }, 1, function(v) hbRestore(); S.hit.part = v end)
end

local TV = newTab("Visuals", "V", "Visuals", "ESP and world rendering")
do
	local g = Card(TV, "ESP")
	Toggle(g, "ESP", S.esp.on, function(v) S.esp.on = v; say("ESP", v) end, "Master switch")
	Toggle(g, "Boxes", S.esp.box, function(v) S.esp.box = v end)
	Toggle(g, "Names", S.esp.name, function(v) S.esp.name = v end)
	Toggle(g, "Health", S.esp.hp, function(v) S.esp.hp = v end)
	Toggle(g, "Distance", S.esp.dist, function(v) S.esp.dist = v end)
	Toggle(g, "Tracers", S.esp.tracer, function(v) S.esp.tracer = v end)
	Toggle(g, "Chams", S.esp.chams, function(v) S.esp.chams = v end, "Nearest 8 only, the game uses highlights too")
	Toggle(g, "Show players", S.esp.plrs, function(v) S.esp.plrs = v end)
	Toggle(g, "Show bots", S.esp.bots, function(v) S.esp.bots = v end)
	Slider(g, "Max distance", 50, 2000, 50, S.esp.maxd, function(v) S.esp.maxd = v end, " st")
	local names = {}
	for i, p in ipairs(PALETTE) do names[i] = p[1] end
	Cycle(g, "Player color", names, 1, function(_, i) S.esp.color = i end)

	local g2 = Card(TV, "World")
	Toggle(g2, "Fullbright", S.vis.full, function(v) S.vis.full = v; setFull(v); say("Fullbright", v) end)
	Toggle(g2, "No fog", S.vis.fog, function(v) S.vis.fog = v; setFog(v); say("No fog", v) end)
	Toggle(g2, "Strip post effects", S.vis.clean, function(v) S.vis.clean = v; setClean(v); say("Strip post effects", v) end, "Blur, bloom, depth of field")
	Toggle(g2, "Custom FOV", S.vis.fov, function(v) S.vis.fov = v; setFov(v) end)
	Slider(g2, "Field of view", 50, 120, 1, S.vis.fovv, function(v) S.vis.fovv = v end)
end

local TM = newTab("Movement", "M", "Movement", "Speed, flight and jump")
do
	local g = Card(TM, "Speed")
	Note(g, "The game simulates movement with its own physics, so the server may pull you back. The Config tab has the raw physics values.")
	Toggle(g, "Speed boost", S.mov.speed, function(v) S.mov.speed = v; say("Speed boost", v) end)
	Slider(g, "Boost", 4, 80, 2, S.mov.speedv, function(v) S.mov.speedv = v end, " st/s")
	Toggle(g, "Humanoid override", S.mov.hum, function(v) S.mov.hum = v; setHum(v) end, "WalkSpeed and JumpPower")
	Slider(g, "WalkSpeed", 16, 120, 1, S.mov.ws, function(v) S.mov.ws = v end)
	Slider(g, "JumpPower", 50, 200, 1, S.mov.jp, function(v) S.mov.jp = v end)

	local g2 = Card(TM, "Air")
	Toggle(g2, "Fly", S.mov.fly, function(v) S.mov.fly = v; say("Fly", v) end, "Stick plus camera pitch steers")
	Slider(g2, "Fly speed", 10, 200, 5, S.mov.flyv, function(v) S.mov.flyv = v end, " st/s")
	Toggle(g2, "Infinite jump", S.mov.ijump, function(v) S.mov.ijump = v end)
end

local function tpTo(cf)
	local r = myRoot()
	if r then
		r.CFrame = cf
		r.AssemblyLinearVelocity = Vector3.zero
	else
		notify("Teleport", "No character yet", "warn")
	end
end

local TW = newTab("World", "W", "World", "Teleports and session tools")
do
	local g = Card(TW, "Teleport")
	Button(g, "Arena center", function()
		local m = wsFind("Map", "Arena", "Middle")
		if m then tpTo(CFrame.new(m.Position + Vector3.new(0, 8, 0))) else notify("Teleport", "Arena not loaded", "warn") end
	end)
	Button(g, "Lobby spawn", function()
		local m = wsFind("Map", "Lobby", "SpawnPoint")
		if m then tpTo(CFrame.new(m.Position + Vector3.new(0, 5, 0))) else notify("Teleport", "Lobby not found", "warn") end
	end, "ghost")
	Button(g, "Nearest enemy", function()
		local root = myRoot()
		if not root then notify("Teleport", "No character yet", "warn"); return end
		local best, bd
		for _, t in ipairs(listTargets(true, true)) do
			local d = (t.root.Position - root.Position).Magnitude
			if not bd or d < bd then best, bd = t, d end
		end
		if best then tpTo(best.root.CFrame * CFrame.new(0, 0, 4)) else notify("Teleport", "No targets", "warn") end
	end, "ghost")

	local g2 = Card(TW, "Session")
	Toggle(g2, "Anti-AFK", S.misc.afk, function(v) S.misc.afk = v end, "Idle kick guard plus a tiny camera nudge")
	Cycle(g2, "FPS cap", { "60", "90", "120", "240" }, 1, function(v)
		if setfpscap then setfpscap(tonumber(v)) else notify("FPS cap", "setfpscap not available", "warn") end
	end)
	Button(g2, "Rejoin server", function()
		pcall(function() TeleportService:TeleportToPlaceInstance(game.PlaceId, game.JobId, LP) end)
	end, "ghost")
	Button(g2, "Server hop", function()
		notify("Server hop", "Searching servers...", "info")
		task.spawn(function()
			local ok, body = pcall(function()
				return game:HttpGet("https://games.roblox.com/v1/games/" .. game.PlaceId .. "/servers/Public?sortOrder=Asc&limit=100")
			end)
			if not ok then notify("Server hop", "Server list request failed", "bad"); return end
			local ok2, data = pcall(function() return HttpService:JSONDecode(body) end)
			if not ok2 or type(data) ~= "table" or type(data.data) ~= "table" then notify("Server hop", "Server list unreadable", "bad"); return end
			for _, s in ipairs(data.data) do
				if s.id ~= game.JobId and s.playing < s.maxPlayers then
					pcall(function() TeleportService:TeleportToPlaceInstance(game.PlaceId, s.id, LP) end)
					return
				end
			end
			notify("Server hop", "No open server found", "warn")
		end)
	end, "ghost")
end

local TCfg = newTab("Config", "#", "Config", "Live edit the game's own config tables")
do
	local g = Card(TCfg, "Source")
	Cycle(g, "Module", CFG_MODULES, 1, function(v) cfgName = v; cfgRender() end)
	Input(g, "Filter, e.g. reach, speed, jump", function(txt) cfgFilter = txt:lower(); cfgRender() end)
	Button(g, "Reset this module", function()
		local fields = cfgFields[cfgName]
		if not fields then return end
		for _, f in ipairs(fields) do cfgSet(f.parent, f.key, f.orig) end
		cfgRender()
		notify("Config", cfgName .. " reset to defaults", "ok")
	end, "ghost")
	local gv = Card(TCfg, "Values")
	cfgInfo = Note(gv, "")
	cfgBox = add(gv, new("Frame", { Size = UDim2.new(1, 0, 0, 0), AutomaticSize = Enum.AutomaticSize.Y, BackgroundTransparency = 1, BorderSizePixel = 0 }))
	new("UIListLayout", { SortOrder = Enum.SortOrder.LayoutOrder }, cfgBox)
end

local TP = newTab("Probe", "P", "Probe", "Map the game's network and modules")
do
	local g = Card(TP, "Tools")
	Note(g, "Turn the spy on, do one action in game, then copy the log. That shows exactly what the game sends.")
	Toggle(g, "Remote spy", S.probe.spy, function(v)
		if v and not installSpy() then
			notify("Remote spy", "Executor lacks hookmetamethod", "bad")
			S.probe.spy = false
			return
		end
		S.probe.spy = v
	end, "Logs MCRemotes FireServer / InvokeServer")
	Toggle(g, "Include Look / Sync", S.probe.spam, function(v) S.probe.spam = v end, "Very noisy")
	Button(g, "Test HIT button signals", function()
		local btn = hitButton()
		if not btn then log("hit: MCTouch.Hit not found (open the in-round HUD first)"); return end
		local names = {}
		for _, n in ipairs(HIT_SIGNALS) do names[#names + 1] = n end
		for _, n in ipairs(INPUT_SIGNALS) do names[#names + 1] = n end
		for _, name in ipairs(names) do
			local ok, list = pcall(getconnections, btn[name])
			if ok and type(list) == "table" then
				log("hit: " .. name .. " -> " .. #list .. " connections")
				for i, c in ipairs(list) do
					if i > 3 then break end
					local okS, full = pcall(function() return getfenv(c.Function).script:GetFullName() end)
					log("   #" .. i .. " from " .. (okS and full or "unknown script"))
				end
			else
				log("hit: " .. name .. " -> getconnections unavailable")
			end
		end
	end, "ghost")
	Button(g, "Fire HIT once", function()
		log("hit: pressHit -> " .. tostring(pressHit()) .. (hubOpen and " (hub open, touch fallback is off)" or ""))
	end, "ghost")
	local labels = {
		"Pof.Camera", "Pof.Movement", "Pof.Sync", "Pof.Chars", "Pof.Touch", "Pof.Hud", "Pof.Fx", "Pof.Viewmodel", "Pof.Inventory", "Pof.World",
		"Shared.Net", "Shared.EntitySync", "Shared.Combat.DamageCalc", "Shared.Physics.PlayerPhysics", "Config.Combat", "Config.Physics",
	}
	local pick = labels[1]
	Cycle(g, "Module", labels, 1, function(v) pick = v end)
	Button(g, "Dump module API", function() dumpModule(pick) end, "ghost")

	local go = Card(TP, "Output")
	LogPane(go, 170)
	Button(go, "Copy log", function()
		if setclipboard then setclipboard(table.concat(logLines, "\n")); notify("Log", "Copied to clipboard", "ok") else notify("Log", "setclipboard not available", "warn") end
	end)
	Button(go, "Save log to file", function()
		if writefile then
			local ok = pcall(writefile, "LunyxToF_log.txt", table.concat(logLines, "\n"))
			notify("Log", ok and "Saved LunyxToF_log.txt" or "writefile failed", ok and "ok" or "bad")
		else
			notify("Log", "writefile not available", "warn")
		end
	end, "ghost")
	Button(go, "Clear log", function() logLines = {}; logDirty = true; if logLabel then logLabel.Text = "" end end, "ghost")
end

local TS = newTab("Settings", "S", "Settings", "Interface and hub controls")
do
	local g = Card(TS, "Interface")
	Slider(g, "UI scale", 0.7, 1.3, 0.05, S.ui.scale, function(v) S.ui.scale = v; rescale() end, "x")
	local an = {}
	for i, a in ipairs(ACCENTS) do an[i] = a[1] end
	Cycle(g, "Accent", an, 1, function(_, i) S.ui.accent = i; setAccent(i) end)
	Toggle(g, "Watermark", S.ui.watermark, function(v) S.ui.watermark = v; Mark.Visible = v end, "FPS and ping, top left")
	Toggle(g, "Active features list", S.ui.active, function(v) S.ui.active = v; refreshActive() end)
	Toggle(g, "Notifications", S.ui.notify, function(v) S.ui.notify = v end)

	local g2 = Card(TS, "Hub")
	Note(g2, "Tap the round L to hide or show the hub. Drag the title bar to move it. On keyboard, RightShift toggles it.")
	Button(g2, "Reset window position", function() Root.Position = UDim2.new(0.5, 0, 0.5, 0) end, "ghost")
	local confirmAt = 0
	Button(g2, "Unload hub", function(b)
		if os.clock() - confirmAt < 2.5 then
			Destroy()
		else
			confirmAt = os.clock()
			b.Text = "Tap again to confirm"
			task.delay(2.5, function() if b.Parent then b.Text = "Unload hub" end end)
		end
	end, "danger")
end

cfgRender()
selectTab(TC)

---------------------------------------------------------------------
-- launcher bubble + window toggle
---------------------------------------------------------------------
local Bubble = new("TextButton", {
	Name = "Bubble", Text = "", AutoButtonColor = false, BackgroundColor3 = WHITE, Size = UDim2.fromOffset(46, 46),
	Position = UDim2.new(0, 16, 0.5, -23), ZIndex = 70, BorderSizePixel = 0,
}, Gui)
corner(Bubble, 23)
gradient(Bubble, 45)
local bubbleStroke = stroke(Bubble, WHITE, 1.5, 0.55)
new("TextLabel", { Text = "L", Font = FONTB, TextSize = 21, TextColor3 = WHITE, BackgroundTransparency = 1, Size = UDim2.new(1, 0, 1, 0), ZIndex = 71 }, Bubble)

local function toggleWin()
	if hubOpen then
		hubOpen = false
		unlockScroll()
		tween(RootScale, 0.16, { Scale = RootScale.Scale * 0.9 }, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
		task.delay(0.16, function()
			if alive and not hubOpen then Root.Visible = false end
		end)
	else
		hubOpen = true
		local target = fitScale * S.ui.scale
		RootScale.Scale = target * 0.9
		Root.Visible = true
		tween(RootScale, 0.28, { Scale = target }, Enum.EasingStyle.Back)
	end
end
local function snapBubble()
	local c = cam()
	if not c then return end
	local vp = c.ViewportSize
	local ap = Bubble.AbsolutePosition
	local x = (ap.X + 23 < vp.X / 2) and 12 or (vp.X - 58)
	local y = clamp(ap.Y, 10, vp.Y - 56)
	tween(Bubble, 0.25, { Position = UDim2.fromOffset(x, y) }, Enum.EasingStyle.Quint)
end
makeDraggable(Bubble, Bubble, toggleWin, snapBubble)
keep(btnMin.MouseButton1Click:Connect(toggleWin))
keep(btnClose.MouseButton1Click:Connect(function() toggleWin() end))
keep(UserInputService.InputBegan:Connect(function(input, gpe)
	if not gpe and input.KeyCode == Enum.KeyCode.RightShift then toggleWin() end
end))

---------------------------------------------------------------------
-- loops
---------------------------------------------------------------------
local lastNudge = os.clock()
local function renderStep(dt)
	local c = cam()
	if not c then return end
	local vp = c.ViewportSize
	aimTarget = nil
	if S.aim.on then
		local t, pos = pickAimTarget(c, vp)
		if t then
			aimTarget = t
			local cf = c.CFrame
			local a = 1 - (1 - S.aim.smooth) ^ (dt * 60)
			c.CFrame = cf:Lerp(CFrame.lookAt(cf.Position, pos), clamp(a, 0, 1))
		end
	end
	circle.Visible = S.aim.on and S.aim.circle
	if circle.Visible then
		circle.Size = UDim2.fromOffset(S.aim.fov * 2, S.aim.fov * 2)
		circle.Position = UDim2.fromOffset(vp.X / 2, vp.Y / 2)
		circleStroke.Color = aimTarget and T.good or A1
	end
	if S.vis.fov then c.FieldOfView = S.vis.fovv end
	if S.misc.afk and os.clock() - lastNudge > 25 then
		lastNudge = os.clock()
		c.CFrame = c.CFrame * CFrame.Angles(0, math.rad(0.15), 0)
	end
	stepEsp(c, vp)
end

RunService:BindToRenderStep("LunyxToFStep", Enum.RenderPriority.Last.Value, function(dt)
	if not alive then return end
	local ok, err = pcall(renderStep, dt)
	if not ok then log("render: " .. tostring(err)) end
end)

local function getPing()
	local ok, v = pcall(function() return Stats.Network.ServerStatsItem["Data Ping"]:GetValue() end)
	return ok and v or 0
end

local acc, statAcc, frames = 0, 0, 0
keep(RunService.Heartbeat:Connect(function(dt)
	if not alive then return end
	pcall(stepMovement, dt)
	pcall(stepTrigger)
	pcall(stepLighting)
	acc = acc + dt
	if acc >= 0.2 then
		acc = 0
		pcall(stepHitbox)
	end
	flushLog()
	frames = frames + 1
	statAcc = statAcc + dt
	if statAcc >= 0.5 then
		local fps = frames / statAcc
		frames, statAcc = 0, 0
		local ping = getPing()
		Mark.Text = string.format('<font color="%s">LUNYX</font>  <font color="%s">%d fps   %d ms</font>', rgbStr(A1), rgbStr(T.sub), math.floor(fps + 0.5), math.floor(ping + 0.5))
		footerLbl.Text = string.format("%d fps  |  %d ms\nv2  |  Delta", math.floor(fps + 0.5), math.floor(ping + 0.5))
		pcall(refreshActive)
	end
end))

if VirtualUser then
	keep(LP.Idled:Connect(function()
		if S.misc.afk then
			pcall(function()
				VirtualUser:CaptureController()
				VirtualUser:ClickButton2(Vector2.new())
			end)
		end
	end))
end

---------------------------------------------------------------------
-- teardown
---------------------------------------------------------------------
Destroy = function()
	if not alive then return end
	alive = false
	for _, c in ipairs(conns) do pcall(function() c:Disconnect() end) end
	pcall(function() RunService:UnbindFromRenderStep("LunyxToFStep") end)
	pcall(hbRestore)
	pcall(setFull, false)
	pcall(setFog, false)
	pcall(setClean, false)
	pcall(setFov, false)
	pcall(setHum, false)
	for _, o in pairs(espObjs) do destroyEsp(o) end
	for _, f in ipairs(cleanups) do pcall(f) end
	pcall(function() espRoot:Destroy() end)
	pcall(function() Gui:Destroy() end)
	pcall(function() Draw:Destroy() end)
	env.__LUNYX_SPYFN = nil
	env.__LUNYX_TOF = nil
end
env.__LUNYX_TOF = { Destroy = Destroy }

if game.PlaceId ~= 108114331578868 then log("note: PlaceId differs from Towers of Fortune") end
Root.Visible = true
refreshActive()
notify("Lunyx loaded", "Tap the L bubble to hide or show the hub", "ok", 3)

Similar Scripts

Voxel Wars Script SFY Hub: Aimbot, ESP

Key System • 10 hours ago

Philly Streetz 2 Script Mint Hub: Auto Farm, Silent Aim

Key System • 10 hours ago

Throw Key for Cars Script GoldHub: Auto Farm, Auto Buy Key

Key System • 10 hours ago

Realistic Ragdoll MMA Script Sportsclub: Godmode, Auto Slip

Key System • 10 hours ago

Throw Food For Animals Script BP Hub: Smart Farm, Auto Buy

Key System • 10 hours ago