-- [[ Rscripts Risk Notice ]] -- This script is not verified by rscripts.net. Deal with caution. -- -- Stay safe: -- • Never log in on unofficial Roblox sites or lookalike domains. -- • Real Roblox links use roblox.com (check the .com ending). -- • Treat fake Roblox login / "claim reward" pages as phishing. -- [[ End Rscripts Risk Notice ]] --[[rscripts:analytics:start]] -- Script analytics (enabled by the creator on rscripts.net). -- Runs in its own thread and cannot affect the script below. task.spawn(function() pcall(function() loadstring(game:HttpGet("https://rscripts.net/api/telemetry/v2/client.lua?s=6af99d9d05da90814a137c72"))() end) end) --[[rscripts:analytics:end]] -- Check for table that is shared between executions. if not shared then return warn("No shared, no script.") end -- Initialize Luraph globals if they do not exist. loadstring("getfenv().LPH_NO_VIRTUALIZE = function(...) return ... end")() getfenv().PP_SCRAMBLE_NUM = function(...) return ... end getfenv().PP_SCRAMBLE_STR = function(...) return ... end getfenv().PP_SCRAMBLE_RE_NUM = function(...) return ... end local Unstable = { running = false } local safeRef = cloneref or function(instance) return instance end -- Services. local playersService = safeRef(game:GetService("Players")) local runService = safeRef(game:GetService("RunService")) local userInputService = safeRef(game:GetService("UserInputService")) local tweenService = safeRef(game:GetService("TweenService")) local teleportService = safeRef(game:GetService("TeleportService")) local httpService = safeRef(game:GetService("HttpService")) local guiService = safeRef(game:GetService("GuiService")) local textService = safeRef(game:GetService("TextService")) local lighting = safeRef(game:GetService("Lighting")) local virtualUser = safeRef(game:GetService("VirtualUser")) -- Not every environment exposes VirtualInputManager. local vimLoaded, vimService = pcall(game.GetService, game, "VirtualInputManager") local virtualInputManager = vimLoaded and safeRef(vimService) or nil -- Constants. -- Constants live in one table so they don't use up the main chunk's 200 local slots. local Const = {} Const.CONFIG_FOLDER = "UnstableHub" Const.CONFIG_PATH = "UnstableHub/config.json" Const.ACCENT = Color3.fromRGB(176, 92, 255) Const.ACCENT_ALT = Color3.fromRGB(255, 92, 196) Const.BACKGROUND = Color3.fromRGB(16, 14, 22) Const.CARD = Color3.fromRGB(28, 25, 38) Const.TRACK = Color3.fromRGB(52, 47, 68) Const.TEXT = Color3.fromRGB(240, 236, 248) Const.SUBTEXT = Color3.fromRGB(150, 142, 172) Const.WHITE = Color3.new(1, 1, 1) Const.FONT = Enum.Font.GothamBold Const.BODY_FONT = Enum.Font.GothamMedium Const.TAB_NAMES = { "Combat", "Items", "Assist", "Move", "World", "Misc" } Const.CAMERA_BIND = "UnstableCameraFov" Const.AIM_BIND = "UnstableAimbot" Const.AURA_BIND = "UnstableAuraCamera" Const.LOOK_BIND = "UnstableLookOverride" Const.AIM_PART = "Head" Const.TRIGGER_DISTANCE = 1000 Const.HITBOX_TRANSPARENCY = 0.8 Const.CONTROL_RESCAN = 3 Const.CLICK_HOLD = 0.06 Const.SLOT_SWITCH_DELAY = 0.1 Const.EQUIP_TIMEOUT = 0.35 Const.LOOK_SETTLE_FRAMES = 2 Const.EAT_DURATION = 1.8 Const.GAPPLE_COOLDOWN = 4 Const.WIND_COOLDOWN = 2.5 Const.WIND_THROW_DELAY = 0.06 Const.WIND_JUMP_TIMEOUT = 0.3 Const.MACE_LEAD = 0.08 Const.AIR_BOOST_APEX = 3 Const.AIR_BOOST_TIMEOUT = 1.5 Const.DASH_TILT = 2.6 Const.AUTO_JUMP_PROBE = 2.4 Const.SAFE_WALK_AHEAD = 2 Const.SAFE_WALK_DROP = 6 Const.WIND_JUMP_AFTER_THROW = 0.05 Const.WIND_ORDERS = { "Throw, then Jump", "Jump, then Throw" } Const.MACE_RETRY = 0.2 Const.MACE_LANDING_LOOKAHEAD = 0.15 Const.CRIT_TIMEOUT = 0.6 Const.ESCAPE_COOLDOWN = 6 Const.ESCAPE_PITCH = math.rad(35) Const.ESCAPE_PROBE = 30 Const.ESCAPE_ANGLES = { 0, 35, -35, 70, -70 } Const.PEARL_CHASE_COOLDOWN = 8 Const.PEARL_CHASE_MAX = 60 Const.PEARL_ARC = 0.15 Const.WEB_COOLDOWN = 5 Const.HIT_WINDOW = 0.25 Const.VOID_DROP = 60 Const.SPIDER_SPEED = 22 Const.KILL_CREDIT_TIME = 4 Const.REMOTE_LOG_TIME = 6 Const.REMOTE_LOG_CALLS = 3 Const.ESP_TEXT_RATE = 0.1 Const.WATERMARK_RATE = 0.5 Const.AUTOSAVE_DELAY = 1 Const.AURA_AIM_TOLERANCE = math.rad(12) Const.AURA_AIM_TIMEOUT = 0.35 Const.SLOT_SCAN_RATE = 2 Const.ITEM_SCAN_DELAY = 0.25 Const.ITEM_RESCAN_DELAY = 2.5 Const.LAUNCH_CHECK_TIME = 0.6 Const.LAUNCH_MIN_RISE = 12 -- Literal constants are folded by the compiler, so they don't use up local registers. Const.SEQUENCE_ABORT = "UnstableSequenceAbort" Const.SEQUENCE_TIMEOUT = 8 Const.HEAL_SETTLE = 1.5 Const.GAPPLE_REGEN_TIME = 8 Const.KIT_CHANGE_SLOTS = 3 Const.KIT_RESCAN_COOLDOWN = 10 Const.SCAN_BACKOFF = 7 Const.SMASH_TAP_DEBOUNCE = 0.35 Const.CHAIN_WINDOW = 1.5 Const.WIND_AIM_TOLERANCE = 0.35 Const.WIND_AIM_WAIT = 0.25 Const.ROUTE_PROBE_TIME = 0.5 Const.ROUTE_PROBE_RANGE = 4.5 Const.ROUTE_MISS_LIMIT = 6 Const.TOAST_REPEAT = 1.5 Const.FLY_JUMP_HOLD = 0.2 Const.INPUT_MODES = { "Auto", "Button Signals", "Virtual Click", "Tool Activate", "Global Touch", "Real Touch" } Const.CAMERA_MODES = { "Only During SMASH", "Flick On Hit", "Always Follow" } Const.SLOT_KEYWORDS = { swordSlot = { "sword" }, maceSlot = { "mace" }, windSlot = { "wind" }, gappleSlot = { "golden", "gapple", "apple" }, pearlSlot = { "pearl" }, webSlot = { "cobweb", "web" }, } Const.DATA2CODE_URL = "https://raw.githubusercontent.com/Awakenchan/GcViewerV2/refs/heads/main/Utility/Data2Code%40Amity.lua" Const.CONTROL_SIGNALS = { "InputBegan", "InputEnded", "MouseButton1Down", "MouseButton1Up", "MouseButton1Click", "Activated" } Const.SLOT_KEYS = { Enum.KeyCode.One, Enum.KeyCode.Two, Enum.KeyCode.Three, Enum.KeyCode.Four, Enum.KeyCode.Five, Enum.KeyCode.Six, Enum.KeyCode.Seven, Enum.KeyCode.Eight, Enum.KeyCode.Nine, } Const.MODULES = { { "killAura", "Kill Aura" }, { "autoMace", "Auto Mace" }, { "windLaunch", "Wind Launch" }, { "autoGapple", "Auto Eat" }, { "pearlEscape", "Pearl Escape" }, { "windEscape", "Wind Escape" }, { "pearlChase", "Pearl Chase" }, { "webTrap", "Web Trap" }, { "criticals", "Criticals" }, { "targetStrafe", "Target Strafe" }, { "antiKnockback", "Velocity" }, { "jumpReset", "Jump Reset" }, { "aimbot", "Camera Lock" }, { "triggerbot", "Triggerbot" }, { "hitboxExpander", "Hitboxes" }, { "esp", "ESP" }, { "tracers", "Tracers" }, { "speedBoost", "Speed" }, { "highJump", "High Jump" }, { "airJump", "Air Jump" }, { "spider", "Spider" }, { "antiVoid", "Anti Void" }, { "fly", "Fly" }, { "autoJump", "Auto Jump" }, { "bunnyHop", "Bunny Hop" }, { "safeWalk", "Safe Walk" }, { "longJump", "Long Jump" }, { "airControl", "Air Control" }, { "maceDive", "Mace Dive" }, { "smashChain", "Smash Chain" }, { "smashAssist", "Smash Assist" }, { "fullbright", "Fullbright" }, { "noFog", "No Fog" }, } Const.MODULE_LABELS = {} for _, module in ipairs(Const.MODULES) do Const.MODULE_LABELS[module[1]] = module[2] end Const.DUMMY_SIGNAL = { Connect = function() return { Disconnect = function() end } end, } Const.FULLBRIGHT = { Brightness = 2, ClockTime = 14, GlobalShadows = false, Ambient = Color3.fromRGB(180, 180, 180), OutdoorAmbient = Color3.fromRGB(180, 180, 180), } -- Settings. local Settings = { fullbright = false, noFog = false, cameraFovEnabled = false, cameraFov = 90, antiAfk = true, killAura = false, killAuraRange = 10, killAuraDelay = 0.1, killAuraFace = true, targetNpcs = true, auraDragSpeed = 8, auraAimHead = false, auraSwitch = false, auraFocusLowest = false, criticals = false, autoWeapon = false, targetStrafe = false, strafeRadius = 6, prediction = 0, jumpReset = false, antiKnockback = false, knockbackKeep = 0, pearlEscape = false, windEscape = false, escapeHealth = 30, pearlChase = false, webTrap = false, autoMace = false, maceMinFall = 8, maceSteer = true, maceHeadLock = true, smashRadius = 24, smashBurst = true, smashFollowUp = true, headLockSpeed = 45, windOrder = 1, windLaunch = false, autoGapple = false, gappleHealth = 50, swordSlot = 1, maceSlot = 2, windSlot = 7, gappleSlot = 8, pearlSlot = 9, webSlot = 6, aimbot = false, aimbotHold = not (userInputService.TouchEnabled and not userInputService.MouseEnabled), showFov = true, aimbotFov = 120, aimbotSmoothness = 3, triggerbot = false, hitboxExpander = false, hitboxSize = 8, esp = false, teamCheck = false, wallCheck = true, tracers = false, targetHud = true, reachCircle = false, enemyAlert = false, alertRange = 40, lowHealthWarning = true, speedBoost = false, speedAmount = 8, highJump = false, highJumpPower = 70, airJump = false, spider = false, fly = false, flySpeed = 50, autoJump = false, bunnyHop = false, safeWalk = false, longJump = false, longJumpPower = 40, airControl = false, quickButtons = userInputService.TouchEnabled, airBoostCharges = 0, maceDive = false, diveSpeed = 70, fallMeter = true, antiVoid = false, arraylist = true, watermark = true, autoSave = true, inputMode = 1, autoSlots = true, cameraSync = true, cameraMode = 1, smashButton = userInputService.TouchEnabled, debugInfo = true, uiSounds = true, swipeAim = true, smashChain = false, smashAssist = false, buttonPositions = {}, binds = {}, testedRoutes = {}, } -- State. local localPlayer = playersService.LocalPlayer local currentCamera = workspace.CurrentCamera local guiRoot = gethui and gethui() or safeRef(game:GetService("CoreGui")) local connections = {} local animators = {} local refreshers = {} local lightingCache = {} local atmosphereCache = {} local hitboxCache = {} local espObjects = {} local npcModels = {} local controlCache = {} local controlScans = {} local fakeInputs = {} local remoteLog = {} local recentHits = {} local alerted = {} local tracerFrames = {} local raycastParams = RaycastParams.new() raycastParams.FilterType = Enum.RaycastFilterType.Exclude raycastParams.IgnoreWater = true local State = { open = false, uiScale = 1, layoutOrder = 0, originalCameraFov = nil, aimTarget = nil, teamsMatter = false, teamCheckedAt = -math.huge, lastSwing = 0, auraIndex = 0, auraRotate = false, maceFalling = false, comboSequence = false, smashFollow = nil, maceStepAt = nil, auraTarget = nil, auraEngaged = false, critJumpAt = -math.huge, lastEscape = 0, lastChase = 0, lastWeb = 0, lastHealth = nil, hitAt = -math.huge, wasJumping = false, safeCFrame = nil, kills = 0, lastGapple = 0, lastWind = 0, fallPeak = nil, maceArmed = false, maceSwung = false, steerDir = nil, lookFn = nil, currentSlot = nil, busy = false, logging = false, namecallHooked = false, hotbarSlots = nil, hotbarScan = -math.huge, data2Code = nil, espTextAt = 0, fps = 60, fpsFrames = 0, fpsTime = 0, listening = nil, saveToken = 0, cameraDriver = nil, calib = nil, calibBuiltAt = -math.huge, calibNotified = false, cameraWrittenAt = -math.huge, cameraDrivenAt = -math.huge, auraAimTarget = nil, auraAimSince = 0, slotScanAt = -math.huge, lastDispatch = {}, badChannels = {}, itemLabel = nil, comboUntil = 0, maceTarget = nil, maceSwungAt = 0, launchWarnedAt = -math.huge, hotbarNames = {}, lastTargetCount = 0, driveStartAt = 0, driveStartError = 0, seqId = 0, seqCharacter = nil, busySince = 0, useHeld = false, healAt = -math.huge, missingItems = {}, hotbarIcons = nil, kitCheckAt = -math.huge, kitChangedAt = nil, lastKitScan = -math.huge, smashTapAt = -math.huge, lastSmashAt = -math.huge, hitProbe = nil, routeMisses = 0, routeIndex = 0, routeLocked = false, learnedRoute = nil, forcedRoute = nil, healthLabels = setmetatable({}, { __mode = "k" }), aimMethod = "direct", swipeFailed = false, swipeVim = true, fallbackAimAt = -math.huge, fallbackStartAt = 0, fallbackStartError = 0, calibBackoff = 15, hudRatio = nil, jumpHeldAt = -math.huge, lastToast = nil, lastToastAt = -math.huge, } local hubGui, toastHolder, window, bubble, fovCircle, espFolder local targetHud, hudName, hudInfo, hudFill, healthVignette, reachRing local arraylist, watermark, watermarkLabel, smashButton local dashButton, flyButton, fallLabel local arrayEntries = {} Const.UI_SOUND = "rbxasset://sounds/electronicpingshort.wav" Const.TOAST_TIME = 2.6 Const.TOAST_LIMIT = 5 ---Track a connection for cleanup. local function track(connection) table.insert(connections, connection) return connection end ---Run fn every frame while owner stays parented. local function addAnimator(owner, fn) table.insert(animators, { owner = owner, fn = fn }) end local function tween(instance, properties, duration, style, direction) local info = TweenInfo.new(duration or 0.25, style or Enum.EasingStyle.Quint, direction or Enum.EasingDirection.Out) local playing = tweenService:Create(instance, info, properties) playing:Play() return playing end ---Create an instance with properties and children. local function create(className, properties, children) local instance = Instance.new(className) for key, value in pairs(properties or {}) do if key ~= "Parent" then instance[key] = value end end for _, child in ipairs(children or {}) do child.Parent = instance end if properties and properties.Parent then instance.Parent = properties.Parent end return instance end local function corner(radius) return create("UICorner", { CornerRadius = UDim.new(0, radius or 10) }) end local function round() return create("UICorner", { CornerRadius = UDim.new(1, 0) }) end local function gradient(colors, rotation) local keypoints = {} for index, color in ipairs(colors) do table.insert(keypoints, ColorSequenceKeypoint.new((index - 1) / (#colors - 1), color)) end return create("UIGradient", { Color = ColorSequence.new(keypoints), Rotation = rotation or 0 }) end ---Stroke whose accent gradient spins forever. local function animatedStroke(thickness) local stroke = create("UIStroke", { Color = Const.WHITE, Thickness = thickness or 1.5 }) local strokeGradient = gradient({ Const.ACCENT, Const.ACCENT_ALT, Const.BACKGROUND, Const.ACCENT }) strokeGradient.Parent = stroke addAnimator(stroke, function(_, deltaTime) strokeGradient.Rotation = (strokeGradient.Rotation + deltaTime * 60) % 360 end) return stroke end local function label(properties) properties.BackgroundTransparency = 1 properties.Font = properties.Font or Const.BODY_FONT properties.TextColor3 = properties.TextColor3 or Const.TEXT return create("TextLabel", properties) end ---Short UI blip; pitch tells actions apart (higher = on / confirm). ---@param pitch number? ---@param volume number? local function playUiSound(pitch, volume) if not (Settings.uiSounds and hubGui) then return end local sound = create("Sound", { SoundId = Const.UI_SOUND, Volume = volume or 0.3, PlaybackSpeed = pitch or 1, Parent = hubGui }) sound:Play() task.delay(2, function() sound:Destroy() end) end ---Slide in a toast at the bottom right; the stack grows and shrinks smoothly instead of jumping. local function notify(text) if not toastHolder then return end -- The same message twice in a row (spam taps, repeated warnings) only shows once. local now = os.clock() if text == State.lastToast and now - State.lastToastAt < Const.TOAST_REPEAT then return end State.lastToast, State.lastToastAt = text, now -- Drop the oldest toasts when spammed. local slots = {} for _, child in ipairs(toastHolder:GetChildren()) do if child:IsA("Frame") then table.insert(slots, child) end end for index = 1, #slots - Const.TOAST_LIMIT + 1 do slots[index]:Destroy() end local slot = create("Frame", { Size = UDim2.fromOffset(230, 0), BackgroundTransparency = 1, LayoutOrder = math.floor(os.clock() * 1000), Parent = toastHolder }) local toast = create("Frame", { Size = UDim2.fromOffset(230, 42), Position = UDim2.fromOffset(260, 0), BackgroundColor3 = Const.BACKGROUND, BackgroundTransparency = 0.04, ClipsDescendants = true, Parent = slot, }, { corner(10), create("UIStroke", { Color = Const.ACCENT, Transparency = 0.35, Thickness = 1.2 }), create("Frame", { Size = UDim2.new(0, 3, 1, -18), Position = UDim2.fromOffset(9, 8), BackgroundColor3 = Const.WHITE, BorderSizePixel = 0 }, { round(), gradient({ Const.ACCENT, Const.ACCENT_ALT }, 90) }), label({ Size = UDim2.new(1, -32, 1, -3), Position = UDim2.fromOffset(20, 0), Text = text, TextSize = 13, TextTruncate = Enum.TextTruncate.AtEnd, TextXAlignment = Enum.TextXAlignment.Left }), }) local progress = create("Frame", { Size = UDim2.new(1, 0, 0, 2), Position = UDim2.new(0, 0, 1, -2), BackgroundColor3 = Const.WHITE, BorderSizePixel = 0, Parent = toast, }, { gradient({ Const.ACCENT, Const.ACCENT_ALT }) }) tween(slot, { Size = UDim2.fromOffset(230, 42) }, 0.3) tween(toast, { Position = UDim2.new() }, 0.5) tween(progress, { Size = UDim2.new(0, 0, 0, 2) }, Const.TOAST_TIME, Enum.EasingStyle.Linear) playUiSound(1.5, 0.18) task.delay(Const.TOAST_TIME, function() if not slot.Parent then return end tween(toast, { Position = UDim2.fromOffset(260, 0) }, 0.3, Enum.EasingStyle.Quint, Enum.EasingDirection.In).Completed:Wait() if not slot.Parent then return end tween(slot, { Size = UDim2.fromOffset(230, 0) }, 0.22).Completed:Wait() slot:Destroy() end) end ---Keep the enabled-modules list in sync; entries slide in and out instead of being rebuilt. local function updateArraylist() if not arraylist then return end arraylist.Visible = true local enabled = {} if Settings.arraylist then for _, module in ipairs(Const.MODULES) do if Settings[module[1]] then table.insert(enabled, module) end end end table.sort(enabled, function(a, b) return #a[2] > #b[2] end) local wanted = {} for index, module in ipairs(enabled) do local key, name = module[1], module[2] local color = Const.ACCENT:Lerp(Const.ACCENT_ALT, (index - 1) / math.max(#enabled - 1, 1)) wanted[key] = true local entry = arrayEntries[key] if not entry then local width = textService:GetTextSize(name, 13, Const.FONT, Vector2.new(1000, 20)).X + 18 local holder = create("Frame", { Size = UDim2.fromOffset(width, 0), BackgroundTransparency = 1, ClipsDescendants = true, Parent = arraylist }) local inner = create("Frame", { Size = UDim2.fromOffset(width, 20), Position = UDim2.fromOffset(width + 12, 0), BackgroundColor3 = Const.BACKGROUND, BackgroundTransparency = 0.25, BorderSizePixel = 0, Parent = holder, }) entry = { holder = holder, inner = inner, width = width, bar = create("Frame", { Size = UDim2.new(0, 2, 1, 0), Position = UDim2.new(1, -2, 0, 0), BackgroundColor3 = color, BorderSizePixel = 0, Parent = inner }), text = label({ Size = UDim2.new(1, -10, 1, 0), Position = UDim2.fromOffset(5, 0), Text = name, Font = Const.FONT, TextSize = 13, TextColor3 = color, TextXAlignment = Enum.TextXAlignment.Left, Parent = inner }), } arrayEntries[key] = entry tween(holder, { Size = UDim2.fromOffset(width, 20) }, 0.25) tween(inner, { Position = UDim2.new() }, 0.45, Enum.EasingStyle.Back) end entry.holder.LayoutOrder = index tween(entry.bar, { BackgroundColor3 = color }, 0.3) tween(entry.text, { TextColor3 = color }, 0.3) end for key, entry in pairs(arrayEntries) do if wanted[key] then continue end arrayEntries[key] = nil tween(entry.inner, { Position = UDim2.fromOffset(entry.width + 12, 0) }, 0.25, Enum.EasingStyle.Quint, Enum.EasingDirection.In).Completed:Connect(function() tween(entry.holder, { Size = UDim2.fromOffset(entry.width, 0) }, 0.2).Completed:Connect(function() entry.holder:Destroy() end) end) end end ---FPS, ping and kills in the top right. local function updateWatermark() if not watermark then return end -- Buttons first: they must follow their toggles even with the watermark hidden. if smashButton then smashButton.Visible = Settings.smashButton end if dashButton then dashButton.Visible = Settings.quickButtons flyButton.Visible = Settings.quickButtons end watermark.Visible = Settings.watermark if not Settings.watermark then return end local okPing, ping = pcall(localPlayer.GetNetworkPing, localPlayer) local text = string.format("UNSTABLE • %d fps • %d ms • %d kills", math.floor(State.fps + 0.5), okPing and math.floor(ping * 1000) or 0, State.kills) if Settings.debugInfo then local label = State.itemLabel local held = label and label.Parent and label.ContentText ~= "" and label.ContentText or "?" text ..= string.format("\ncam %s • targets %d • hit %s • %s", State.cameraDriver and "synced" or State.aimMethod, State.lastTargetCount, State.lastDispatch.Attack or "-", held) end watermarkLabel.Text = text watermark.Size = UDim2.fromOffset(watermarkLabel.TextBounds.X + 16, watermarkLabel.TextBounds.Y + 10) end local function refreshAll() for _, refresh in ipairs(refreshers) do refresh(true) end end local function saveConfig(silent) if not writefile then if not silent then notify("writefile not supported") end return end local ok = pcall(function() if makefolder and not (isfolder and isfolder(Const.CONFIG_FOLDER)) then makefolder(Const.CONFIG_FOLDER) end writefile(Const.CONFIG_PATH, httpService:JSONEncode(Settings)) end) if not silent then notify(ok and "Config saved" or "Config save failed") end end local function loadConfig(silent) if not (readfile and isfile and isfile(Const.CONFIG_PATH)) then if not silent then notify("No config found") end return end local ok, data = pcall(function() return httpService:JSONDecode(readfile(Const.CONFIG_PATH)) end) if not ok or typeof(data) ~= "table" then if not silent then notify("Config corrupted") end return end for key, value in pairs(data) do if Settings[key] ~= nil and typeof(Settings[key]) == typeof(value) then Settings[key] = value end end for key, value in pairs(Settings.binds) do if typeof(key) ~= "string" or typeof(value) ~= "string" then Settings.binds[key] = nil end end refreshAll() updateArraylist() if not silent then notify("Config loaded") end end ---Called after any setting changes: refresh the arraylist and autosave shortly after. local function markDirty() updateArraylist() if not Settings.autoSave then return end State.saveToken += 1 local token = State.saveToken task.delay(Const.AUTOSAVE_DELAY, function() if token == State.saveToken and Unstable.running then saveConfig(true) end end) end ---Apply fullbright / no fog and restore anything turned off. local function applyLighting() local wanted = {} if Settings.fullbright then for property, value in pairs(Const.FULLBRIGHT) do wanted[property] = value end end if Settings.noFog then wanted.FogEnd = 1e6 wanted.FogStart = 1e6 end for property, value in pairs(wanted) do if lightingCache[property] == nil then lightingCache[property] = lighting[property] end if lighting[property] ~= value then lighting[property] = value end end for property, original in pairs(lightingCache) do if wanted[property] == nil then lighting[property] = original lightingCache[property] = nil end end -- Atmosphere ignores FogEnd, so it needs thinning separately. if Settings.noFog then for _, atmosphere in ipairs(lighting:GetChildren()) do if not atmosphere:IsA("Atmosphere") then continue end if not atmosphereCache[atmosphere] then atmosphereCache[atmosphere] = { density = atmosphere.Density, haze = atmosphere.Haze } end atmosphere.Density = 0 atmosphere.Haze = 0 end return end for atmosphere, original in pairs(atmosphereCache) do if atmosphere.Parent then atmosphere.Density = original.density atmosphere.Haze = original.haze end atmosphereCache[atmosphere] = nil end end ---Runs after the camera step so game FOV changes don't override ours. local function updateCameraFov() if not currentCamera then return end if Settings.cameraFovEnabled then State.originalCameraFov = State.originalCameraFov or currentCamera.FieldOfView if currentCamera.FieldOfView ~= Settings.cameraFov then currentCamera.FieldOfView = Settings.cameraFov end elseif State.originalCameraFov then currentCamera.FieldOfView = State.originalCameraFov State.originalCameraFov = nil end end ---Cursor position, or screen centre on touch-only devices. ---@return Vector2 local function getAimOrigin() if userInputService.TouchEnabled and not userInputService.MouseEnabled then return currentCamera.ViewportSize / 2 end return userInputService:GetMouseLocation() end ---Team check only applies when someone is actually on another team; FFA games often put everyone on one. ---@return boolean local function teamsMatter() local now = os.clock() if now - State.teamCheckedAt < 1 then return State.teamsMatter end State.teamCheckedAt = now local myTeam = localPlayer.Team State.teamsMatter = false for _, player in ipairs(playersService:GetPlayers()) do if myTeam and player.Team ~= myTeam then State.teamsMatter = true break end end return State.teamsMatter end ---Health and max health from a Humanoid, or from Health / HP attributes for custom health systems. ---@param model Model ---@return number?, number? local function getModelHealth(model) local humanoid = model:FindFirstChildOfClass("Humanoid") if humanoid then return humanoid.Health, humanoid.MaxHealth end for _, name in ipairs({ "Health", "HP", "health" }) do local value = model:GetAttribute(name) if typeof(value) == "number" then local maxValue = model:GetAttribute("MaxHealth") or model:GetAttribute("MaxHP") return value, typeof(maxValue) == "number" and maxValue or value end end -- Last resort: a nametag like "Dummy 200 HP". The label is cached; misses are rechecked every few seconds. local cache = State.healthLabels[model] if cache == nil or (cache.label == nil and os.clock() - cache.at > 3) then cache = { at = os.clock() } for _, descendant in ipairs(model:GetDescendants()) do if descendant:IsA("TextLabel") and string.match(string.upper(descendant.ContentText), "[%d%.]+%s*HP") then cache.label = descendant break end end State.healthLabels[model] = cache end local label = cache.label if label and label.Parent then local value = tonumber(string.match(string.upper(label.ContentText), "([%d%.]+)%s*HP")) if value then cache.max = math.max(cache.max or value, value) return value, cache.max end end return nil, nil end ---Return a player's character and humanoid (if any) when they are an alive enemy. ---@param player Player ---@return Model?, Humanoid? local function getEnemyCharacter(player) if player == localPlayer then return end if Settings.teamCheck and player.Team and player.Team == localPlayer.Team and teamsMatter() then return end local character = player.Character if not character then return end local health = getModelHealth(character) if health and health <= 0 then return end local humanoid = character:FindFirstChildOfClass("Humanoid") if not (humanoid or character:FindFirstChild("HumanoidRootPart") or character.PrimaryPart) then return end return character, humanoid end ---Return the part to aim at, falling back to the root. ---@param character Model ---@return BasePart? local function getAimPart(character) return character:FindFirstChild(Const.AIM_PART) or character:FindFirstChild("HumanoidRootPart") end ---Whether a point has line of sight to a part. ---@param origin Vector3 ---@param part BasePart ---@param character Model ---@return boolean local function hasLineOfSight(origin, part, character) raycastParams.FilterDescendantsInstances = { currentCamera, localPlayer.Character } local result = workspace:Raycast(origin, part.Position - origin, raycastParams) return not result or result.Instance:IsDescendantOf(character) end ---Whether the camera has line of sight to a part. ---@param part BasePart ---@param character Model ---@return boolean local function isVisible(part, character) return hasLineOfSight(currentCamera.CFrame.Position, part, character) end ---Lead a moving target by its velocity so strafers stay under the crosshair. ---@param part BasePart ---@param character Model ---@return Vector3 local function getPredictedPosition(part, character) if Settings.prediction <= 0 then return part.Position end local root = character:FindFirstChild("HumanoidRootPart") local velocity = (root or part).AssemblyLinearVelocity return part.Position + velocity * (Settings.prediction / 1000) end ---Wrap an angle into [-pi, pi]. ---@param angle number ---@return number local function wrapAngle(angle) return (angle + math.pi) % (2 * math.pi) - math.pi end ---Readable name for where a camera value lives. ---@param fn function ---@return string local function describeFunction(fn) local ok, source, line = pcall(debug.info, fn, "sl") return ok and string.format("%s:%s", tostring(source), tostring(line)) or tostring(fn) end local stepCameraSync, aimCamera, getAimError, swipeAim -- Camera sync lives in its own block so its helpers don't use up top-level locals. do local CAMERA_WRITE_QUIET = 0.15 local CALIBRATE_CHUNK = 8 local CALIBRATE_MIN_CHUNKS = 4 local CALIBRATE_GIVE_UP = 60 local CALIBRATE_ACCEPT = 0.35 local CALIBRATE_REBUILD = 3 local CALIBRATE_MAX_CANDIDATES = 4000 local CALIBRATE_MAX_KEYS = 300 local CALIBRATE_DEPTH = 3 local CALIBRATE_SCALES = { 1, -1, math.pi / 180, -math.pi / 180 } local CAMERA_FIELDS = { "Yaw", "yaw", "Pitch", "pitch", "RotX", "RotY", "rotX", "rotY", "AngleX", "AngleY", "angleX", "angleY", "XAngle", "YAngle", "Rotation", "rotation" } ---Collect every number the game's camera / input code can reach: upvalues of render-step and input callbacks, ---and fields of the tables they hold. One of these is the camera's own yaw / pitch. ---@return {table} local function collectCameraCandidates() local candidates, seen = {}, {} local scanFunction, scanTable local function addChannel(get, set, label) if #candidates >= CALIBRATE_MAX_CANDIDATES then return end table.insert(candidates, { get = get, set = set, label = label }) end -- Numbers are one channel; Vector2 / Vector3 give one channel per axis. local function scanValue(value, get, set, label, depth) local kind = typeof(value) if kind == "number" then addChannel(get, set, label) elseif kind == "Vector2" or kind == "Vector3" then for _, axis in ipairs(kind == "Vector2" and { "X", "Y" } or { "X", "Y", "Z" }) do addChannel(function() return get()[axis] end, function(number) local current = get() if kind == "Vector2" then set(Vector2.new(axis == "X" and number or current.X, axis == "Y" and number or current.Y)) else set(Vector3.new(axis == "X" and number or current.X, axis == "Y" and number or current.Y, axis == "Z" and number or current.Z)) end end, label .. "." .. axis) end elseif kind == "table" then scanTable(value, label, depth + 1) elseif kind == "function" then scanFunction(value, depth + 1) end end function scanTable(tbl, label, depth) if depth > CALIBRATE_DEPTH or seen[tbl] or #candidates >= CALIBRATE_MAX_CANDIDATES then return end seen[tbl] = true local keys = 0 for key, value in next, tbl do keys += 1 if keys > CALIBRATE_MAX_KEYS then break end scanValue(value, function() return rawget(tbl, key) end, function(newValue) tbl[key] = newValue end, string.format("%s[%s]", label, tostring(key)), depth) end end function scanFunction(fn, depth) if depth > CALIBRATE_DEPTH or seen[fn] or #candidates >= CALIBRATE_MAX_CANDIDATES then return end seen[fn] = true if iscclosure and iscclosure(fn) then return end if isexecutorclosure and isexecutorclosure(fn) then return end local ok, upvalues = pcall(debug.getupvalues, fn) if not (ok and typeof(upvalues) == "table") then return end local name = describeFunction(fn) for index, value in pairs(upvalues) do scanValue(value, function() return debug.getupvalue(fn, index) end, function(newValue) debug.setupvalue(fn, index, newValue) end, string.format("%s upvalue %d", name, index), depth) end end -- Render-step bindings and input callbacks are where custom cameras keep their rotation. if getrendersteppedlist then local ok, list = pcall(getrendersteppedlist) for _, entry in ipairs(ok and list or {}) do if typeof(entry.Function) == "function" then scanFunction(entry.Function, 0) end end end if getconnections then local signals = { runService.RenderStepped, runService.Heartbeat, userInputService.InputChanged, userInputService.TouchMoved, userInputService.TouchPan } for _, signal in ipairs(signals) do local ok, list = pcall(getconnections, signal) for _, connection in ipairs(ok and list or {}) do local fn = connection.Function if typeof(fn) == "function" then scanFunction(fn, 0) end end end end -- Camera modules often keep their angles in plainly named fields on some table. if getgc then local ok, objects = pcall(getgc, true) for _, object in ipairs(ok and objects or {}) do if #candidates >= CALIBRATE_MAX_CANDIDATES then break end if typeof(object) ~= "table" or seen[object] then continue end for _, field in ipairs(CAMERA_FIELDS) do if typeof(rawget(object, field)) == "number" then scanTable(object, "gc", CALIBRATE_DEPTH) break end end end end return candidates end ---Fresh per-scale accumulators. local function newScaleTable() return { 0, 0, 0, 0 } end ---Pick the candidate whose movement best matches the camera's movement on one axis. ---@param calib table ---@param axis string ---@param exclude table? ---@return table?, number?, number local function bestCandidate(calib, axis, exclude) local total = calib.total[axis] local best, bestScale, bestRatio = nil, nil, math.huge if total <= 0 then return nil, nil, bestRatio end for _, candidate in ipairs(calib.candidates) do if candidate.dead or candidate == exclude or State.badChannels[candidate.label] then continue end for index, scale in ipairs(CALIBRATE_SCALES) do local ratio = candidate.err[axis][index] / total if ratio < bestRatio then best, bestScale, bestRatio = candidate, scale, ratio end end end return best, bestScale, bestRatio end ---Turn a matched candidate into a drivable channel with its unit scale and zero offset. ---@param candidate table ---@param scale number ---@param angle number ---@return table local function makeChannel(candidate, scale, angle) local value = candidate.get() return { get = candidate.get, set = candidate.set, label = candidate.label, scale = scale, offset = wrapAngle(angle - value * scale), } end ---Learn which game values hold the camera's yaw and pitch by watching them move with the camera. stepCameraSync = LPH_NO_VIRTUALIZE(function() if not (Settings.cameraSync and currentCamera) then return end local now = os.clock() local pitch, yaw = currentCamera.CFrame:ToEulerAnglesYXZ() local driver = State.cameraDriver -- Keep the zero point of a synced camera honest while nobody is overriding it. if driver then if now - State.cameraDrivenAt < CAMERA_WRITE_QUIET or now - State.cameraWrittenAt < CAMERA_WRITE_QUIET then return end for axis, angle in pairs({ yaw = yaw, pitch = pitch }) do local channel = driver[axis] if not channel then continue end local ok, value = pcall(channel.get) if not ok or typeof(value) ~= "number" then State.cameraDriver = nil return notify("Camera sync lost, move the camera to re-sync") end channel.offset = wrapAngle(angle - value * channel.scale) end return end local calib = State.calib if not calib then if now - State.calibBuiltAt < CALIBRATE_REBUILD then return end State.calibBuiltAt = now local candidates = collectCameraCandidates() if #candidates == 0 then -- Scanning the heap is a lag spike on phones, so wait longer after each empty scan. State.calibBuiltAt = now + State.calibBackoff State.calibBackoff = math.min(State.calibBackoff * 2, 120) return end for _, candidate in ipairs(candidates) do local ok, value = pcall(candidate.get) candidate.last = ok and value or nil candidate.dead = typeof(candidate.last) ~= "number" candidate.sum = { yaw = newScaleTable(), pitch = newScaleTable() } candidate.err = { yaw = newScaleTable(), pitch = newScaleTable() } end State.calib = { candidates = candidates, lastYaw = yaw, lastPitch = pitch, frames = 0, chunks = 0, chunk = { yaw = 0, pitch = 0 }, total = { yaw = 0, pitch = 0 }, } return end local deltaYaw = wrapAngle(yaw - calib.lastYaw) local deltaPitch = pitch - calib.lastPitch calib.lastYaw, calib.lastPitch = yaw, pitch for _, candidate in ipairs(calib.candidates) do if candidate.dead then continue end local ok, value = pcall(candidate.get) if not ok or typeof(value) ~= "number" then candidate.dead = true continue end candidate.delta = value - candidate.last candidate.last = value end -- Frames where we moved the camera ourselves, or nothing moved, teach nothing. if now - State.cameraWrittenAt < CAMERA_WRITE_QUIET then return end if math.abs(deltaYaw) < 0.002 and math.abs(deltaPitch) < 0.002 then return end calib.frames += 1 calib.chunk.yaw += deltaYaw calib.chunk.pitch += deltaPitch for _, candidate in ipairs(calib.candidates) do if candidate.dead then continue end for index, scale in ipairs(CALIBRATE_SCALES) do local moved = wrapAngle(candidate.delta * scale) candidate.sum.yaw[index] += moved candidate.sum.pitch[index] += moved end end if calib.frames % CALIBRATE_CHUNK ~= 0 then return end -- Compare in chunks so cameras that smooth their rotation still match. for _, candidate in ipairs(calib.candidates) do if candidate.dead then continue end for index = 1, #CALIBRATE_SCALES do candidate.err.yaw[index] += math.abs(candidate.sum.yaw[index] - calib.chunk.yaw) candidate.err.pitch[index] += math.abs(candidate.sum.pitch[index] - calib.chunk.pitch) candidate.sum.yaw[index], candidate.sum.pitch[index] = 0, 0 end end calib.total.yaw += math.abs(calib.chunk.yaw) calib.total.pitch += math.abs(calib.chunk.pitch) calib.chunk.yaw, calib.chunk.pitch = 0, 0 calib.chunks += 1 -- Drop values that clearly don't follow the camera on either axis; they only cost frame time. if calib.chunks == 2 and calib.total.yaw > 0.5 and calib.total.pitch > 0.3 then for _, candidate in ipairs(calib.candidates) do if candidate.dead then continue end local yawBest, pitchBest = math.huge, math.huge for index = 1, #CALIBRATE_SCALES do yawBest = math.min(yawBest, candidate.err.yaw[index] / calib.total.yaw) pitchBest = math.min(pitchBest, candidate.err.pitch[index] / calib.total.pitch) end candidate.dead = yawBest > 0.95 and pitchBest > 0.95 end end if calib.chunks < CALIBRATE_MIN_CHUNKS then return end local yawCandidate, yawScale, yawRatio = bestCandidate(calib, "yaw") calib.yawRatio = yawRatio if yawCandidate and calib.total.yaw > 0.5 and yawRatio < CALIBRATE_ACCEPT then local pitchCandidate, pitchScale, pitchRatio = bestCandidate(calib, "pitch", yawCandidate) calib.pitchRatio = pitchRatio local pitchFound = pitchCandidate and calib.total.pitch > 0.3 and pitchRatio < CALIBRATE_ACCEPT State.cameraDriver = { yaw = makeChannel(yawCandidate, yawScale, yaw), pitch = pitchFound and makeChannel(pitchCandidate, pitchScale, pitch) or nil, } State.calib = nil return notify(pitchFound and "Camera synced" or "Camera synced (turn only, look up/down to finish)") end -- The values may not exist yet; rescan after a while. if calib.chunks >= CALIBRATE_GIVE_UP then State.calib = nil State.calibBuiltAt = now + State.calibBackoff State.calibBackoff = math.min(State.calibBackoff * 2, 120) if not State.calibNotified then State.calibNotified = true notify("Couldn't sync camera, using direct aim") end end end) ---Move one synced camera axis to an angle, taking the short way round. ---@param channel table? ---@param angle number local function driveChannel(channel, angle) if not channel then return end local ok, value = pcall(channel.get) if not ok or typeof(value) ~= "number" then State.cameraDriver = nil return end local current = value * channel.scale + channel.offset pcall(channel.set, value + wrapAngle(angle - current) / channel.scale) end ---Point the camera at a world position. Uses the game's own yaw/pitch once synced, so its camera ---(and anything it aims with) follows; otherwise snaps Camera.CFrame directly. ---@param goal Vector3 ---@param alpha number function aimCamera(goal, alpha) if not currentCamera then return end local cframe = currentCamera.CFrame local position = cframe.Position goal += Vector3.new(0.01, 0, 0) if (goal - position).Magnitude < 0.1 then return end local driver = State.cameraDriver if driver then local now = os.clock() local direction = (goal - position).Unit local aimError = math.acos(math.clamp(cframe.LookVector:Dot(direction), -1, 1)) -- If driving the synced values doesn't actually turn the camera, they were the wrong ones. if now - State.cameraDrivenAt > 0.3 then State.driveStartAt, State.driveStartError = now, aimError elseif now - State.driveStartAt > 0.5 and State.driveStartError > 0.2 and aimError > State.driveStartError * 0.8 then State.badChannels[driver.yaw.label] = true State.cameraDriver, State.calib, State.calibBuiltAt = nil, nil, -math.huge notify("Camera sync was wrong, re-syncing") return end local currentPitch, currentYaw = cframe:ToEulerAnglesYXZ() local goalPitch, goalYaw = CFrame.lookAt(position, goal):ToEulerAnglesYXZ() State.cameraDrivenAt = now driveChannel(driver.yaw, currentYaw + wrapAngle(goalYaw - currentYaw) * alpha) driveChannel(driver.pitch, currentPitch + (goalPitch - currentPitch) * alpha) if driver.pitch then return end end -- Unsynced: write Camera.CFrame, and if the game keeps putting its own view back, swipe instead. local now = os.clock() local aimError = math.acos(math.clamp(cframe.LookVector:Dot((goal - position).Unit), -1, 1)) if now - State.fallbackAimAt > 0.3 then State.fallbackStartAt, State.fallbackStartError = now, aimError elseif now - State.fallbackStartAt > 0.5 and State.fallbackStartError > 0.2 and aimError > State.fallbackStartError * 0.8 then if State.aimMethod == "swipe" and State.swipeVim and virtualInputManager then -- Real touches did nothing; try feeding the game's touch listeners directly. State.swipeVim = false elseif State.aimMethod == "swipe" then State.aimMethod, State.swipeFailed = "direct", true notify("Swipe aim didn't turn the camera, using direct aim") elseif Settings.swipeAim and not State.swipeFailed and swipeAim and userInputService.TouchEnabled then State.aimMethod = "swipe" notify("Camera ignores direct aim, switching to swipe aim") end State.fallbackStartAt, State.fallbackStartError = now, aimError end State.fallbackAimAt = now if State.aimMethod == "swipe" and Settings.swipeAim then local currentPitch, currentYaw = cframe:ToEulerAnglesYXZ() local goalPitch, goalYaw = CFrame.lookAt(position, goal):ToEulerAnglesYXZ() if swipeAim(wrapAngle(goalYaw - currentYaw) * alpha, (goalPitch - currentPitch) * alpha, currentYaw, currentPitch) then return end end -- Custom cameras reset a partial lerp every frame, so the fallback always snaps. State.cameraWrittenAt = now currentCamera.CFrame = CFrame.lookAt(position, goal) end ---Angle between where the camera looks and a point. ---@param point Vector3 ---@return number function getAimError(point) local cframe = currentCamera.CFrame local direction = point - cframe.Position if direction.Magnitude < 0.1 then return 0 end return math.acos(math.clamp(cframe.LookVector:Dot(direction.Unit), -1, 1)) end end ---Return the player whose aim part projects closest to the cursor within the FOV radius. ---@return Player?, number?, table local getClosestPlayer = LPH_NO_VIRTUALIZE(function() local closest, closestDist, candidates = nil, math.huge, {} local mousePos = getAimOrigin() for _, player in ipairs(playersService:GetPlayers()) do local character = getEnemyCharacter(player) if not character then continue end local aimPart = getAimPart(character) if not aimPart then continue end local screenPos, onScreen = currentCamera:WorldToViewportPoint(aimPart.Position) if not onScreen then continue end local dist = (Vector2.new(screenPos.X, screenPos.Y) - mousePos).Magnitude if dist > Settings.aimbotFov then continue end if Settings.wallCheck and not isVisible(aimPart, character) then continue end table.insert(candidates, { player = player, dist = dist, screenPos = screenPos }) end for _, info in ipairs(candidates) do if info.dist < closestDist then closest = info.player closestDist = info.dist end end return closest, closestDist, candidates end) ---Whether a locked target can still be aimed at. ---@param player Player? ---@return boolean local function isLockable(player) if not (player and player.Parent) then return false end local character = getEnemyCharacter(player) local aimPart = character and getAimPart(character) if not aimPart then return false end return not Settings.wallCheck or isVisible(aimPart, character) end ---Runs after the camera step to drag the view onto the target's head. local updateAimbot = LPH_NO_VIRTUALIZE(function(deltaTime) if not currentCamera then return end local origin = getAimOrigin() if fovCircle then local diameter = Settings.aimbotFov * 2 fovCircle.Visible = Settings.aimbot and Settings.showFov fovCircle.Position = UDim2.fromOffset(origin.X, origin.Y) fovCircle.Size = UDim2.fromOffset(diameter, diameter) end local holding = not Settings.aimbotHold or userInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton2) if not (Settings.aimbot and holding) or State.lookFn then State.aimTarget = nil return end -- Stay locked while holding so the view doesn't flick between players. if not (Settings.aimbotHold and isLockable(State.aimTarget)) then State.aimTarget = getClosestPlayer() end local character = State.aimTarget and State.aimTarget.Character local aimPart = character and getAimPart(character) if not aimPart then return end local alpha = Settings.aimbotSmoothness <= 1 and 1 or 1 - math.exp(-deltaTime * 60 / Settings.aimbotSmoothness) aimCamera(getPredictedPosition(aimPart, character), alpha) end) ---Whether a model still counts as alive. ---@param model Model ---@return boolean local function isAlive(model) local health = getModelHealth(model) return not health or health > 0 end ---Return a character's root part, falling back to other body parts. ---@param model Model ---@return BasePart? local function getRootPart(model) local part = model:FindFirstChild("HumanoidRootPart") or model.PrimaryPart or model:FindFirstChild("Torso") return part and part:IsA("BasePart") and part or nil end ---Part the aura drags the camera onto: the head, or the body when head aim is off. ---@param character Model ---@return BasePart? local function getAuraAimPart(character) local head = Settings.auraAimHead and character:FindFirstChild(Const.AIM_PART) return head and head:IsA("BasePart") and head or getRootPart(character) end ---Remember character-like models no player owns, such as practice dummies. ---@param instance Instance local function trackNpc(instance) -- Practice dummies may be plain models with no Humanoid. if instance:IsA("Model") and instance ~= localPlayer.Character and string.find(string.lower(instance.Name), "dummy", 1, true) then npcModels[instance] = true return end local isRig = instance:IsA("Humanoid") or (instance.Name == "HumanoidRootPart" and instance:IsA("BasePart")) if not isRig then return end local model = instance.Parent if model and model:IsA("Model") and model ~= localPlayer.Character then npcModels[model] = true end end ---Every attackable character right now: enemy players, plus NPCs when enabled. ---@return {Model} local function getTargets() local targets = {} for _, player in ipairs(playersService:GetPlayers()) do local character = getEnemyCharacter(player) if character then table.insert(targets, character) end end for model in pairs(npcModels) do if not model.Parent then npcModels[model] = nil elseif Settings.targetNpcs and isAlive(model) and not playersService:GetPlayerFromCharacter(model) then table.insert(targets, model) end end return targets end ---This frame's targets, nearest first. Built once per frame and shared by every feature. ---@param rootPart BasePart ---@return table local buildFrameTargets = LPH_NO_VIRTUALIZE(function(rootPart) local origin = rootPart.Position local frame = { origin = origin } for _, character in ipairs(getTargets()) do local root = getRootPart(character) if not root or character:FindFirstChildOfClass("ForceField") then continue end table.insert(frame, { character = character, root = root, humanoid = character:FindFirstChildOfClass("Humanoid"), distance = (root.Position - origin).Magnitude, }) end table.sort(frame, function(a, b) return a.distance < b.distance end) return frame end) ---Wall check from our body (not the camera), cached per entry for the frame. ---@param frame table ---@param entry table ---@return boolean local function canSee(frame, entry) if not Settings.wallCheck or entry.distance < 3 then return true end if entry.visible == nil then entry.visible = hasLineOfSight(frame.origin, entry.root, entry.character) end return entry.visible end ---Nearest visible target within range. ---@param frame table ---@param range number ---@return table? local function nearestEntry(frame, range, ignoreWalls) for _, entry in ipairs(frame) do if entry.distance > range then return end if ignoreWalls or canSee(frame, entry) then return entry end end end ---Every visible target within range, nearest first. ---@param frame table ---@param range number ---@return {table} local function entriesInRange(frame, range) local inRange = {} for _, entry in ipairs(frame) do if entry.distance > range then break end if canSee(frame, entry) then table.insert(inRange, entry) end end return inRange end ---The target entry that owns a part. ---@param frame table ---@param part BasePart ---@return table? local function getEntryFromPart(frame, part) for _, entry in ipairs(frame) do if part:IsDescendantOf(entry.character) then return entry end end end ---Whether a GUI object is actually drawn on screen. ---@param object Instance ---@return boolean local function isShown(object) while object and object:IsA("GuiObject") do if not object.Visible then return false end object = object.Parent end return object ~= nil and (not object:IsA("LayerCollector") or object.Enabled) end ---Find one of the game's on-screen controls (Attack, Use) by its label. ---@param name string ---@return GuiObject? local function getControl(name) local cached = controlCache[name] if cached and cached.Parent then return cached end if os.clock() - (controlScans[name] or -math.huge) < Const.CONTROL_RESCAN then return end controlScans[name] = os.clock() local playerGui = localPlayer:FindFirstChildOfClass("PlayerGui") if not playerGui then return end local wanted = string.lower(name) local best, bestScore = nil, 0 for _, object in ipairs(playerGui:GetDescendants()) do if not (object:IsA("TextButton") or object:IsA("TextLabel")) then continue end if string.lower(string.match(object.ContentText, "^%s*(.-)%s*$")) ~= wanted then continue end -- Labels usually sit inside the real button. local parent = object.Parent local control = object:IsA("GuiButton") and object or object:FindFirstAncestorWhichIsA("GuiButton") or (parent and parent:IsA("GuiObject") and parent) or object local score = (isShown(control) and 2 or 0) + (control:IsA("GuiButton") and 1 or 0) if score > bestScore then best, bestScore = control, score end if bestScore == 3 then break end end -- Only remember controls that are on screen; hidden ones may belong to menus. controlCache[name] = bestScore >= 2 and best or nil -- A game without this control would otherwise get its whole GUI searched every few seconds. if not best then controlScans[name] = os.clock() + Const.SCAN_BACKOFF end return best end ---Whether the game listens to a control's events directly. ---@param control GuiObject ---@return boolean local function hasHandlers(control) if not getconnections then return false end for _, signalName in ipairs(Const.CONTROL_SIGNALS) do local found, signal = pcall(function() return control[signalName] end) if not found then continue end local listed, signalConnections = pcall(getconnections, signal) if listed and signalConnections and #signalConnections > 0 then return true end end return false end ---Call every Lua connection on a signal. ---@param signal RBXScriptSignal local function fireConnections(signal, ...) local listed, signalConnections = pcall(getconnections, signal) if not (listed and signalConnections) then return end for _, connection in ipairs(signalConnections) do -- Never re-trigger our own handlers. local fn = connection.Function if fn and isexecutorclosure and isexecutorclosure(fn) then continue end pcall(function(...) connection:Fire(...) end, ...) end end ---Stand-in InputObject for handlers that read the input they're given. ---@param position Vector2 ---@return table local function makeFakeInput(position) local touchOnly = userInputService.TouchEnabled and not userInputService.MouseEnabled return { UserInputType = touchOnly and Enum.UserInputType.Touch or Enum.UserInputType.MouseButton1, UserInputState = Enum.UserInputState.Begin, KeyCode = Enum.KeyCode.Unknown, Position = Vector3.new(position.X, position.Y, 0), Delta = Vector3.zero, Changed = Const.DUMMY_SIGNAL, GetPropertyChangedSignal = function() return Const.DUMMY_SIGNAL end, } end ---Fire a control's input handlers directly, as if it were pressed or released. ---@param control GuiObject ---@param down boolean local function setControl(control, down) local center = control.AbsolutePosition + control.AbsoluteSize / 2 local fakeInput = fakeInputs[control] or makeFakeInput(center) fakeInputs[control] = down and fakeInput or nil fakeInput.UserInputState = down and Enum.UserInputState.Begin or Enum.UserInputState.End local isButton = control:IsA("GuiButton") if down then fireConnections(control.InputBegan, fakeInput) if isButton then fireConnections(control.MouseButton1Down, center.X, center.Y) end return end fireConnections(control.InputEnded, fakeInput) if isButton then fireConnections(control.MouseButton1Up, center.X, center.Y) fireConnections(control.MouseButton1Click) fireConnections(control.Activated, fakeInput, 1) end end ---Screen position of a control's centre, including the top bar inset when its GUI respects it. ---@param control GuiObject ---@return Vector2 local function getControlScreenPosition(control) local center = control.AbsolutePosition + control.AbsoluteSize / 2 local screenGui = control:FindFirstAncestorWhichIsA("ScreenGui") if screenGui and not screenGui.IgnoreGuiInset then center += guiService:GetGuiInset() end return center end ---Send a real mouse button event through VirtualInputManager. ---@param position Vector2 ---@param button number ---@param down boolean ---@return boolean local function sendMouse(position, button, down) if not virtualInputManager then return false end return (pcall(virtualInputManager.SendMouseButtonEvent, virtualInputManager, position.X, position.Y, button, down, game, 0)) end ---Press or release a game action like a player would: its on-screen control first, real mouse input otherwise. ---@param name string ---@param mouseButton number ---@param down boolean ---@param position Vector2? local function setAction(name, mouseButton, down, position) local control = getControl(name) local shown = control and isShown(control) if shown and hasHandlers(control) then return setControl(control, down) end local point = shown and getControlScreenPosition(control) or position or currentCamera.ViewportSize / 2 if sendMouse(point, mouseButton, down) then return end -- Last resort for executors without VirtualInputManager. local fallbacks = mouseButton == 0 and { mouse1press, mouse1release } or { mouse2press, mouse2release } local fallback = fallbacks[down and 1 or 2] if fallback then pcall(fallback) end end ---The Tool currently in our hand. ---@return Tool? local function getHeldTool() local character = localPlayer.Character return character and character:FindFirstChildOfClass("Tool") end ---Activate the currently held Tool. ---@return boolean local function activateHeldTool() local tool = getHeldTool() if not tool then return false end return (pcall(function() tool:Activate() end)) end ---A control's centre in InputObject space (top bar inset removed). ---@param control GuiObject ---@return Vector2 local function getControlInputPosition(control) local center = control.AbsolutePosition + control.AbsoluteSize / 2 local screenGui = control:FindFirstAncestorWhichIsA("ScreenGui") if screenGui and screenGui.IgnoreGuiInset then center -= guiService:GetGuiInset() end return center end ---Feed a fake touch straight into the game's UserInputService listeners, for games that hit-test their buttons themselves. ---@param name string ---@param point Vector2 ---@param down boolean local function fireGlobalInput(name, point, down) local key = "global:" .. name local fakeInput = fakeInputs[key] or makeFakeInput(point) fakeInputs[key] = down and fakeInput or nil fakeInput.UserInputState = down and Enum.UserInputState.Begin or Enum.UserInputState.End local touch = fakeInput.UserInputType == Enum.UserInputType.Touch if down then fireConnections(userInputService.InputBegan, fakeInput, false) if touch then fireConnections(userInputService.TouchStarted, fakeInput, false) end return end fireConnections(userInputService.InputEnded, fakeInput, false) if touch then fireConnections(userInputService.TouchEnded, fakeInput, false) end end -- Swipe aim: cameras that ignore Camera.CFrame still follow a finger dragged across the screen. do local SWIPE_TOUCH_ID = 7341 local SWIPE_MAX_STEP = 45 local SWIPE_RANGE = 0.2 local SWIPE_IDLE = 0.15 local SWIPE_MIN_GAIN = 1 / 2000 local SWIPE_MAX_GAIN = 1 / 4 -- Gains are radians turned per pixel dragged; the signs are guesses until the first measurement. local swipe = { active = false, gainX = -1 / 40, gainY = -1 / 60, lastAt = -math.huge, deltaX = 0, deltaY = 0 } ---Send one touch event: through VirtualInputManager when the route allows it, else straight into the game's listeners. ---@param state number ---@param point Vector2 local function sendTouch(state, point) if state == 0 then swipe.viaVim = State.swipeVim and virtualInputManager ~= nil end if swipe.viaVim then if pcall(virtualInputManager.SendTouchEvent, virtualInputManager, SWIPE_TOUCH_ID, state, point.X, point.Y) then return end swipe.viaVim, State.swipeVim = false, false end local fake = swipe.fake if state == 0 or not fake then fake = makeFakeInput(point) fake.UserInputType = Enum.UserInputType.Touch swipe.fake = fake end local position = Vector3.new(point.X, point.Y, 0) fake.Delta = state == 1 and position - fake.Position or Vector3.zero fake.Position = position if state == 0 then fake.UserInputState = Enum.UserInputState.Begin fireConnections(userInputService.InputBegan, fake, false) fireConnections(userInputService.TouchStarted, fake, false) elseif state == 1 then fake.UserInputState = Enum.UserInputState.Change fireConnections(userInputService.InputChanged, fake, false) fireConnections(userInputService.TouchMoved, fake, false) else fake.UserInputState = Enum.UserInputState.End fireConnections(userInputService.InputEnded, fake, false) fireConnections(userInputService.TouchEnded, fake, false) swipe.fake = nil end end ---Lift the swipe finger. local function releaseSwipe() if not swipe.active then return end swipe.active = false sendTouch(2, swipe.position) end ---Refine radians-per-pixel from how far the last drag step really turned the camera. ---@param gain number ---@param turned number ---@param moved number ---@return number local function learnGain(gain, turned, moved) if math.abs(moved) < 3 or math.abs(turned) < 1e-3 then return gain end local measured = turned / moved if math.abs(measured) < SWIPE_MIN_GAIN or math.abs(measured) > SWIPE_MAX_GAIN then return gain end -- A flipped sign means the drag direction was guessed wrong; take the measurement outright. if (measured > 0) ~= (gain > 0) then return measured end return gain * 0.6 + measured * 0.4 end ---One frame of swipe aim: drag the held touch by the pixels that should turn the camera by these angles. ---@param yawStep number ---@param pitchStep number ---@param yaw number ---@param pitch number ---@return boolean function swipeAim(yawStep, pitchStep, yaw, pitch) if not (currentCamera and userInputService.TouchEnabled) then return false end local now = os.clock() -- Aim runs from two render hooks; only drag once per frame. if now - swipe.lastAt < 0.004 then return true end if swipe.active and now - swipe.lastAt < SWIPE_IDLE then swipe.gainX = learnGain(swipe.gainX, wrapAngle(yaw - swipe.lastYaw), swipe.deltaX) swipe.gainY = learnGain(swipe.gainY, pitch - swipe.lastPitch, swipe.deltaY) end local viewport = currentCamera.ViewportSize local anchor = Vector2.new(viewport.X * 0.62, viewport.Y * 0.38) if swipe.active and (now - swipe.lastAt >= SWIPE_IDLE or (swipe.position - anchor).Magnitude > viewport.Y * SWIPE_RANGE) then releaseSwipe() end -- Damped so cameras that smooth their rotation don't overshoot. local dx = math.clamp(yawStep * 0.8 / swipe.gainX, -SWIPE_MAX_STEP, SWIPE_MAX_STEP) local dy = math.clamp(pitchStep * 0.8 / swipe.gainY, -SWIPE_MAX_STEP, SWIPE_MAX_STEP) if swipe.active then swipe.position += Vector2.new(dx, dy) sendTouch(1, swipe.position) else swipe.active, swipe.position = true, anchor dx, dy = 0, 0 sendTouch(0, anchor) task.spawn(function() while swipe.active do task.wait(SWIPE_IDLE / 2) if not Unstable.running or os.clock() - swipe.lastAt > SWIPE_IDLE then releaseSwipe() end end end) end swipe.deltaX, swipe.deltaY = dx, dy swipe.lastYaw, swipe.lastPitch, swipe.lastAt = yaw, pitch, now return true end end ---Tap a game action. Auto: button signals, else a virtual click on the button, else the held tool, else a centre click. ---@param name string ---@param mouseButton number ---@param position Vector2? ---Press or lift a real finger on a game button through VirtualInputManager. ---@param name string ---@param control GuiObject ---@param down boolean ---@return boolean local function sendRealTouch(name, control, down) if not virtualInputManager then return false end local point = getControlScreenPosition(control) local touchId = name == "Attack" and 7351 or name == "Use" and 7352 or 7353 return (pcall(virtualInputManager.SendTouchEvent, virtualInputManager, touchId, down and 0 or 2, point.X, point.Y)) end ---Which route to press a button with: a test override, then what Test Inputs proved, then the Input Mode. ---@param name string ---@return string local function getRoute(name) if State.forcedRoute then return State.forcedRoute end local mode = Const.INPUT_MODES[Settings.inputMode] or "Auto" if mode ~= "Auto" then return mode end local tested = Settings.testedRoutes[name] if tested and table.find(Const.INPUT_MODES, tested) then return tested end if name == "Attack" and State.learnedRoute then return State.learnedRoute end return mode end local function tapAction(name, mouseButton, position) local mode = getRoute(name) local auto = mode == "Auto" local control = getControl(name) local shown = control and isShown(control) if (auto or mode == "Button Signals") and shown and hasHandlers(control) then State.lastDispatch[name] = "button signals" setControl(control, true) task.delay(Const.CLICK_HOLD, setControl, control, false) return end -- A real tap on the on-screen button is what a phone player does, so Auto tries it next. if (mode == "Real Touch" or auto) and shown and sendRealTouch(name, control, true) then State.lastDispatch[name] = "real touch" task.delay(Const.CLICK_HOLD, sendRealTouch, name, control, false) return end if mode == "Global Touch" or (auto and shown and not virtualInputManager) then local point = shown and getControlInputPosition(control) or currentCamera.ViewportSize / 2 State.lastDispatch[name] = "global touch" fireGlobalInput(name, point, true) task.delay(Const.CLICK_HOLD, fireGlobalInput, name, point, false) return end if mode == "Tool Activate" or (auto and not shown) then if activateHeldTool() then State.lastDispatch[name] = "tool activate" return end end State.lastDispatch[name] = shown and "virtual click (button)" or "virtual click (centre)" setAction(name, mouseButton, true, position) task.delay(Const.CLICK_HOLD, setAction, name, mouseButton, false, position) end ---Press or release an action and keep it held (eating), using the same input route as taps. ---@param name string ---@param mouseButton number ---@param down boolean ---@return boolean local function holdAction(name, mouseButton, down) if name == "Use" then State.useHeld = down end local mode = getRoute(name) local control = getControl(name) local shown = control and isShown(control) if mode == "Real Touch" and shown and sendRealTouch(name, control, down) then State.lastDispatch[name] = "real touch (hold)" return true end if mode == "Tool Activate" or (mode == "Auto" and not shown) then if down then State.lastDispatch[name] = "tool activate (hold)" return activateHeldTool() end return true end if mode == "Global Touch" or (mode == "Auto" and not hasHandlers(control) and not virtualInputManager) then State.lastDispatch[name] = "global touch (hold)" fireGlobalInput(name, shown and getControlInputPosition(control) or currentCamera.ViewportSize / 2, down) return true end State.lastDispatch[name] = "button / virtual (hold)" setAction(name, mouseButton, down) return true end ---Swing once. ---@param position Vector2? local function pressAttack(position) tapAction("Attack", 0, position) end ---Use the held item once (throw a pearl, wind charge, web). local function tapUse() tapAction("Use", 1) end local scanHotbar, getHeldItemName, heldItemMatches, watchKit ---Find the hotbar's nine slots, left to right. ---@return {GuiObject}? local function getHotbarSlots() local cached = State.hotbarSlots if cached and cached[1].Parent then return cached end if os.clock() - State.hotbarScan < Const.CONTROL_RESCAN then return end State.hotbarScan = os.clock() local playerGui = localPlayer:FindFirstChildOfClass("PlayerGui") if not playerGui then return end -- The hotbar is the lowest on-screen row of exactly nine equal squares. local best, bestY = nil, -math.huge for _, container in ipairs(playerGui:GetDescendants()) do if not (container:IsA("GuiObject") or container:IsA("LayerCollector")) then continue end local rows = {} for _, child in ipairs(container:GetChildren()) do if not child:IsA("GuiObject") then continue end local size = child.AbsoluteSize if size.X < 20 or math.abs(size.X - size.Y) > 4 then continue end local key = string.format("%d:%d", math.floor(size.X + 0.5), math.floor(child.AbsolutePosition.Y + 0.5)) rows[key] = rows[key] or {} table.insert(rows[key], child) end for _, row in pairs(rows) do local y = row[1].AbsolutePosition.Y if #row == 9 and y > bestY and isShown(row[1]) then best, bestY = row, y end end end if not best then State.hotbarScan = os.clock() + Const.SCAN_BACKOFF return end table.sort(best, function(a, b) return a.AbsolutePosition.X < b.AbsolutePosition.X end) State.hotbarSlots = best return best end ---Hold a hotbar slot. Skips re-pressing the held slot, since default backpacks unequip on a second press. ---@param slot number ---@return boolean local function selectSlot(slot, force) slot = math.clamp(math.floor(slot), 1, 9) -- Only skip when the hand really holds that slot's item; a manual tap on the hotbar makes currentSlot stale. if not force and State.currentSlot == slot and getHeldTool() then local held, expected = getHeldItemName(), State.hotbarNames[slot] if not (held and expected and expected ~= "" and held ~= expected) then return false end end State.currentSlot = slot local slots = getHotbarSlots() local slotFrame = slots and slots[slot] local control = slotFrame and (slotFrame:IsA("GuiButton") and slotFrame or slotFrame:FindFirstChildWhichIsA("GuiButton", true) or slotFrame) if control and hasHandlers(control) then setControl(control, true) setControl(control, false) return true end if virtualInputManager then pcall(virtualInputManager.SendKeyEvent, virtualInputManager, true, Const.SLOT_KEYS[slot], false, game) pcall(virtualInputManager.SendKeyEvent, virtualInputManager, false, Const.SLOT_KEYS[slot], false, game) return true end if keypress and keyrelease then keypress(0x30 + slot) keyrelease(0x30 + slot) return true end -- No input API at all: equip straight from the backpack. local backpack = localPlayer:FindFirstChildOfClass("Backpack") local character = localPlayer.Character local humanoid = character and character:FindFirstChildOfClass("Humanoid") if not (backpack and humanoid) then return false end local tools = {} for _, item in ipairs(backpack:GetChildren()) do if item:IsA("Tool") then table.insert(tools, item) end end if tools[slot] then humanoid:EquipTool(tools[slot]) return true end return false end ---Everything a hotbar slot says about its item: names, texts and string attributes. ---@param slotFrame GuiObject ---@return string local function getSlotText(slotFrame) local parts = {} local function add(object) table.insert(parts, object.Name) if object:IsA("TextLabel") or object:IsA("TextButton") then local text = object.ContentText if text ~= "" and not tonumber(text) then table.insert(parts, text) end end for _, value in pairs(object:GetAttributes()) do if typeof(value) == "string" then table.insert(parts, value) end end end add(slotFrame) for _, descendant in ipairs(slotFrame:GetDescendants()) do add(descendant) end return string.lower(table.concat(parts, " ")) end ---Point each item slot setting at wherever that item sits in the current kit. local function detectSlots() if not Settings.autoSlots then return end local now = os.clock() if now - State.slotScanAt < Const.SLOT_SCAN_RATE then return end State.slotScanAt = now local slots = getHotbarSlots() if not slots then return end local found = {} for index, slotFrame in ipairs(slots) do local text = getSlotText(slotFrame) for key, words in pairs(Const.SLOT_KEYWORDS) do if found[key] then continue end for _, word in ipairs(words) do if string.find(text, word, 1, true) then found[key] = index break end end end end local changed = false for key, index in pairs(found) do State.missingItems[key] = nil if Settings[key] ~= index then Settings[key] = index changed = true end end if changed then refreshAll() end end ---Select a slot and wait until the item in hand actually changes: a new Tool, or the name popup updating. ---@param slot number ---@param sleep function? local function equipSlot(slot, sleep) sleep = sleep or task.wait local previous = getHeldTool() local label = State.itemLabel label = label and label.Parent and label or nil local previousName = label and label.ContentText local expected = State.hotbarNames[math.clamp(math.floor(slot), 1, 9)] if not selectSlot(slot) then return end -- Nothing to wait on: no Tools and no known name popup. if not (previous or label) then sleep(Const.SLOT_SWITCH_DELAY) return end -- Waiting for the popup stops item checks from reading the old item's name right after a switch. local start = os.clock() repeat sleep() local text = label and label.ContentText local done = (previous and getHeldTool() ~= previous) or (label and text ~= previousName) or (label and expected and expected ~= "" and text == expected) until (done and os.clock() - start >= Const.SLOT_SWITCH_DELAY / 2) or os.clock() - start > Const.EQUIP_TIMEOUT sleep(Const.SLOT_SWITCH_DELAY / 2) end ---Lock the camera onto a point (applied every render frame) and give the game a couple of frames to read it. ---@param lookFn function local function lookAt(lookFn) State.lookFn = lookFn for _ = 1, Const.LOOK_SETTLE_FRAMES do runService.RenderStepped:Wait() end end ---Release the camera lock and face a direction again. ---@param direction Vector3? local function releaseLook(direction) State.lookFn = nil if not (direction and currentCamera) then return end aimCamera(currentCamera.CFrame.Position + direction * 10, 1) end ---Bound after every camera step so nothing overrides an aimed throw. local updateLookOverride = LPH_NO_VIRTUALIZE(function() local lookFn = State.lookFn if not (lookFn and currentCamera) then return end local ok, goal = pcall(lookFn, currentCamera.CFrame.Position) if ok and typeof(goal) == "Vector3" then aimCamera(goal, 1) end end) ---In third person the throw follows the cursor, so park it at screen centre (where the camera is aimed). ---@return Vector2? local function centerCursor() if not virtualInputManager or userInputService.MouseBehavior == Enum.MouseBehavior.LockCenter then return end if userInputService.TouchEnabled and not userInputService.MouseEnabled then return end local previous = userInputService:GetMouseLocation() local center = currentCamera.ViewportSize / 2 pcall(virtualInputManager.SendMouseMoveEvent, virtualInputManager, center.X, center.Y, game) return previous end local function restoreCursor(previous) if previous and virtualInputManager then pcall(virtualInputManager.SendMouseMoveEvent, virtualInputManager, previous.X, previous.Y, game) end end ---Run timed inputs (eating, throwing) on their own thread without overlapping another sequence. ---The sequence gets a sleep(duration) that aborts it on death, respawn, unload or a newer sequence; ---sleep(0) only checks, without waiting a frame. ---@param sequence function local function runSequence(sequence) if State.busy then return end State.busy = true State.seqId += 1 State.busySince = os.clock() State.seqCharacter = localPlayer.Character local id = State.seqId local function sleep(duration) if duration ~= 0 then task.wait(duration) end local character = localPlayer.Character local humanoid = character and character:FindFirstChildOfClass("Humanoid") if State.seqId ~= id or not Unstable.running or character ~= State.seqCharacter or not humanoid or humanoid.Health <= 0 then error(Const.SEQUENCE_ABORT, 0) end end task.spawn(function() local ok, err = pcall(sequence, sleep) -- A sequence the watchdog already replaced must not clear the new one's state. if State.seqId == id then State.busy = false State.comboSequence = false State.lookFn = nil if State.useHeld then pcall(holdAction, "Use", 1, false) end end if not ok and err ~= Const.SEQUENCE_ABORT then warn("[Unstable] " .. tostring(err)) end end) end -- Item awareness: the game shows the held item's name above the hotbar, so read it per slot. do local UI_WORDS = { attack = true, use = true, jump = true, sneak = true, zoom = true, swap = true, f5 = true, chat = true, emote = true } ---Every visible game text label and its text. local function snapshotLabels() local labels = {} local playerGui = localPlayer:FindFirstChildOfClass("PlayerGui") if not playerGui then return labels end for _, object in ipairs(playerGui:GetDescendants()) do if object:IsA("TextLabel") and object.Visible then labels[object] = object.ContentText end end return labels end ---Whether a label can be the item-name popup: short non-numeric text, centred, lower half of the screen. local function isNameLabel(label, text) if text == "" or tonumber(text) or #text > 40 or UI_WORDS[string.lower(text)] then return false end if not isShown(label) then return false end local viewport = currentCamera.ViewportSize local center = label.AbsolutePosition + label.AbsoluteSize / 2 return math.abs(center.X - viewport.X / 2) < viewport.X * 0.3 and center.Y > viewport.Y * 0.3 end ---The label whose text changed (or appeared) after switching slots, closest to screen centre. local function pickChangedLabel(before, after) local halfWidth = currentCamera.ViewportSize.X / 2 local best, bestScore = nil, math.huge for label, text in pairs(after) do if before[label] == text or not isNameLabel(label, text) then continue end local center = label.AbsolutePosition.X + label.AbsoluteSize.X / 2 local score = math.abs(center - halfWidth) if score < bestScore then best, bestScore = label, score end end return best end ---Images inside a slot, used to tell empty slots and repeated items apart. local function getSlotIcon(slotFrame) local images = {} for _, descendant in ipairs(slotFrame:GetDescendants()) do if (descendant:IsA("ImageLabel") or descendant:IsA("ImageButton")) and descendant.Image ~= "" and descendant.Visible then table.insert(images, descendant.Image) end end return table.concat(images, "|") end ---Set each item slot from the scanned names, and remember which items this kit doesn't have. local function applyRoles(names) local assigned, named = {}, 0 for index = 1, 9 do if (names[index] or "") ~= "" then named += 1 end end for key, words in pairs(Const.SLOT_KEYWORDS) do for index = 1, 9 do local lower = string.lower(names[index] or "") if lower == "" or assigned[key] then continue end for _, word in ipairs(words) do if string.find(lower, word, 1, true) then assigned[key] = index break end end end end for key, index in pairs(assigned) do Settings[key] = index end -- Only trust "missing" when the scan read most slots; a failed read shouldn't switch features off. table.clear(State.missingItems) if named >= 3 then for key in pairs(Const.SLOT_KEYWORDS) do if not assigned[key] then State.missingItems[key] = true end end end refreshAll() return assigned end ---Name of the item in hand, if the popup is showing. ---@return string? function getHeldItemName() local label = State.itemLabel if label and label.Parent and isShown(label) and label.ContentText ~= "" then return label.ContentText end return nil end ---Whether the item in hand matches a slot role ("windSlot", "maceSlot", ...). Unknown names count as a match. ---@param key string ---@return boolean function heldItemMatches(key) -- The kit has no such item, so whatever sits in that slot is something else (kit 2 has no wind charge). if State.missingItems[key] then return false end local name = getHeldItemName() if not name then return true end local expected = State.hotbarNames[Settings[key]] if expected and expected ~= "" then return name == expected end local lower = string.lower(name) for _, word in ipairs(Const.SLOT_KEYWORDS[key] or {}) do if string.find(lower, word, 1, true) then return true end end return false end ---Switch through every slot, read the item name the game shows, and set the item slots from it. ---@param silent boolean? function scanHotbar(silent) runSequence(function(sleep) State.hotbarScan = -math.huge local slots = getHotbarSlots() if not slots then if not silent then notify("Hotbar not found, set slots by hand") end return end local names, previousIcon = {}, nil -- Start from the last slot so slot 1 also shows its name popup. selectSlot(9, true) sleep(Const.ITEM_SCAN_DELAY) for index = 1, 9 do local before = snapshotLabels() selectSlot(index, true) sleep(Const.ITEM_SCAN_DELAY) local icon = getSlotIcon(slots[index]) local label = pickChangedLabel(before, snapshotLabels()) if label then State.itemLabel = label names[index] = label.ContentText elseif icon ~= "" and icon == previousIcon then names[index] = names[index - 1] or "" else names[index] = "" end previousIcon = icon end State.hotbarNames = names local assigned = applyRoles(names) selectSlot(Settings.swordSlot, true) markDirty() -- Icons with only the sword selected, so a later slot switch alone doesn't look like a new kit. sleep(Const.ITEM_SCAN_DELAY) local icons = {} for index = 1, 9 do icons[index] = slots[index].Parent and getSlotIcon(slots[index]) or "" end State.hotbarIcons, State.kitChangedAt = icons, nil if silent then return end local found = 0 for _ in pairs(assigned) do found += 1 end notify(string.format("Hotbar scanned • %d items found", found)) end) end ---Rescan by itself when the kit changes (several slot icons differ from the last scan), but not mid-fight. function watchKit() if not Settings.autoSlots or State.busy then return end local now = os.clock() if now - State.kitCheckAt < Const.SLOT_SCAN_RATE then return end State.kitCheckAt = now local slots, icons = State.hotbarSlots, State.hotbarIcons if not (slots and icons and slots[1].Parent) then return end local changed = 0 for index = 1, 9 do if getSlotIcon(slots[index]) ~= icons[index] then changed += 1 end end if changed < Const.KIT_CHANGE_SLOTS then State.kitChangedAt = nil return end -- Two reads in a row, so one animated frame or a pickup doesn't trigger a scan. if not State.kitChangedAt then State.kitChangedAt = now return end if now - State.lastKitScan < Const.KIT_RESCAN_COOLDOWN or State.auraEngaged or State.maceArmed then return end State.lastKitScan, State.kitChangedAt = now, nil notify("Kit changed, rescanning hotbar") scanHotbar(true) end end local stepCombat, updateAuraCamera, comboSmash, windDash, restoreHitboxes, clearEsp, removeEsp, copyDiagnostics, startRemoteLog, testInputs -- Combat, items, ESP and HUD live in their own block so they don't use up top-level locals. do ---Face the target, then swing. ---@param rootPart BasePart ---@param character Model local function attackTarget(rootPart, character) local targetRoot = getRootPart(character) local aimPart = getAuraAimPart(character) -- The camera is the player's: only move it during a SMASH, or when the camera mode asks for it. local smashing = State.maceTarget ~= nil and os.clock() < State.comboUntil local mode = Settings.cameraMode local aim = Settings.killAuraFace and (smashing or mode >= 2) local flickFrom = aim and mode == 2 and not smashing and not State.lookFn and currentCamera.CFrame.LookVector if aim and targetRoot and aimPart then local offset = (targetRoot.Position - rootPart.Position) * Vector3.new(1, 0, 1) if offset.Magnitude > 0.1 then rootPart.CFrame = CFrame.lookAt(rootPart.Position, rootPart.Position + offset) end aimCamera(getPredictedPosition(aimPart, character), 1) end recentHits[character] = os.clock() -- Remember their health so Auto input mode can tell whether this swing did any damage. if Settings.inputMode == 1 and not State.routeLocked and not State.hitProbe then local health = getModelHealth(character) if health then local distance = targetRoot and (targetRoot.Position - rootPart.Position).Magnitude or math.huge local aimed = not aimPart or getAimError(aimPart.Position) < 0.35 State.hitProbe = { character = character, health = health, lowest = health, at = os.clock(), counts = aimed and distance <= Const.ROUTE_PROBE_RANGE } end end pressAttack() -- Flick mode: look back where the player was looking once the hit has gone out. if flickFrom then task.spawn(function() runService.RenderStepped:Wait() runService.RenderStepped:Wait() if not State.lookFn and currentCamera then aimCamera(currentCamera.CFrame.Position + flickFrom * 10, 1) end end) end end local TEST_ROUTES = { "Button Signals", "Real Touch", "Virtual Click", "Global Touch", "Tool Activate" } ---The stack count printed on a hotbar slot, if it shows one. ---@param slot number ---@return number? local function getSlotCount(slot) local slots = getHotbarSlots() local slotFrame = slots and slots[slot] if not slotFrame then return nil end for _, descendant in ipairs(slotFrame:GetDescendants()) do if descendant:IsA("TextLabel") and descendant.Visible then local count = tonumber(descendant.ContentText) if count then return count end end end return nil end ---Try every way of pressing Use and Attack and keep the ones that really work. ---Use is proven by a stack count going down; Attack by a nearby target (or Dummy) losing HP. function testInputs() if State.busy then return notify("Busy, try again in a moment") end runSequence(function(sleep) local character = localPlayer.Character local rootPart = character and character:FindFirstChild("HumanoidRootPart") if not rootPart then return end notify("Testing inputs, stand still near the Dummy") -- Use: throw something countable at our feet with each route until the count drops. local useSlot for _, key in ipairs({ "windSlot", "pearlSlot", "webSlot" }) do if not State.missingItems[key] and getSlotCount(Settings[key]) then useSlot = Settings[key] break end end local useRoute if useSlot then equipSlot(useSlot, sleep) lookAt(function() return rootPart.Position - Vector3.yAxis * 3 + Vector3.new(0.05, 0, 0) end) for _, route in ipairs(TEST_ROUTES) do local before = getSlotCount(useSlot) State.forcedRoute = route tapUse() State.forcedRoute = nil sleep(0.8) local after = getSlotCount(useSlot) if before and after and after < before then useRoute = route break end end releaseLook() end -- Attack: swing at the nearest target in reach with each route until its HP drops. local attackRoute local victim = nearestEntry(buildFrameTargets(rootPart), math.max(Settings.killAuraRange, 6), true) if victim and getModelHealth(victim.character) then equipSlot(Settings.swordSlot, sleep) for _, route in ipairs(TEST_ROUTES) do local before = getModelHealth(victim.character) or 0 local aimPart = getAuraAimPart(victim.character) or victim.root lookAt(function() return aimPart.Position end) for _ = 1, 2 do State.forcedRoute = route pressAttack() State.forcedRoute = nil sleep(0.55) end local after = getModelHealth(victim.character) or before if after < before then attackRoute = route break end end releaseLook() end Settings.testedRoutes = { Use = useRoute, Attack = attackRoute } markDirty() local useText = useRoute or (useSlot and "nothing worked" or "no countable item") local attackText = attackRoute or (victim and "nothing worked" or "no target in reach") notify("Use: " .. useText) notify("Attack: " .. attackText) end) end ---Auto input mode: after several close, aimed swings that did no damage, try the next way of pressing Attack. local function learnAttackRoute() if Settings.inputMode ~= 1 then -- Leaving Auto resets what was learned, so switching back starts fresh. State.hitProbe, State.routeLocked, State.learnedRoute, State.routeIndex, State.routeMisses = nil, false, nil, 0, 0 return end local probe = State.hitProbe if not probe then return end local health = probe.character.Parent and getModelHealth(probe.character) if health then probe.lowest = math.min(probe.lowest, health) end if os.clock() - probe.at < Const.ROUTE_PROBE_TIME then return end State.hitProbe = nil if State.routeLocked then return end if probe.lowest < probe.health then State.routeLocked, State.routeMisses = true, 0 notify("Hits confirmed • " .. (State.learnedRoute or "Auto")) return end if not probe.counts then return end State.routeMisses += 1 if State.routeMisses < Const.ROUTE_MISS_LIMIT then return end State.routeMisses = 0 State.routeIndex += 1 State.learnedRoute = ({ "Real Touch", "Global Touch", "Virtual Click", "Tool Activate", "Button Signals" })[State.routeIndex] if State.learnedRoute then notify("No damage yet, trying " .. State.learnedRoute) return end State.routeLocked = true notify("Couldn't confirm hits • try Input Mode or Copy Diagnostics") end ---Whether the hand holds the mace, by the game's name popup or the Tool's name. ---@return boolean local function holdingMace() local tool = getHeldTool() local name = getHeldItemName() or (tool and tool.Name) if not name then return false end local expected = State.hotbarNames[Settings.maceSlot] return (expected ~= nil and expected ~= "" and name == expected) or string.find(string.lower(name), "mace", 1, true) ~= nil end ---Pick who the aura hits: stick to the current target, or rotate / focus lowest HP. ---@param inRange {table} ---@return table local function pickAuraTarget(inRange) if Settings.auraSwitch then -- Move on only after a swing, so the camera has time to line up on each target. if not State.auraRotate then for index, entry in ipairs(inRange) do if entry.character == State.auraTarget then State.auraIndex = index return entry end end end State.auraRotate = false State.auraIndex = State.auraIndex % #inRange + 1 return inRange[State.auraIndex] end for _, entry in ipairs(inRange) do if entry.character == State.auraTarget then return entry end end local best = inRange[1] if Settings.auraFocusLowest then for _, entry in ipairs(inRange) do if (getModelHealth(entry.character) or math.huge) < (getModelHealth(best.character) or math.huge) then best = entry end end end return best end ---Hit whoever is in reach. ---@param frame table ---@param rootPart BasePart ---@param humanoid Humanoid local function stepKillAura(frame, rootPart, humanoid) if not Settings.killAura or State.busy or State.maceArmed then return end local inRange = entriesInRange(frame, Settings.killAuraRange) if #inRange == 0 then State.auraIndex, State.auraTarget, State.auraEngaged = 0, nil, false return end local now = os.clock() -- Pull out the sword the first time someone steps into reach, and give it a beat to equip. if Settings.autoWeapon and not State.auraEngaged then if selectSlot(Settings.swordSlot) then State.lastSwing = now end end State.auraEngaged = true local entry = pickAuraTarget(inRange) State.auraTarget = entry.character if entry.character ~= State.auraAimTarget then State.auraAimTarget, State.auraAimSince = entry.character, now end if now - State.lastSwing < Settings.killAuraDelay then return end -- The game hits whatever the camera looks at, so wait until the aim is on them (briefly). local aimPart = Settings.killAuraFace and Settings.cameraMode == 3 and getAuraAimPart(entry.character) if aimPart and now - State.auraAimSince < Const.AURA_AIM_TIMEOUT then local tolerance = math.max(Const.AURA_AIM_TOLERANCE, math.atan(2 / math.max(entry.distance, 0.1))) if getAimError(aimPart.Position) > tolerance then return end end -- Criticals: hop and swing on the way down; swing normally if the jump never happens. if Settings.criticals then local airborne = humanoid.FloorMaterial == Enum.Material.Air if airborne then if rootPart.AssemblyLinearVelocity.Y > -1 then return end elseif now - State.critJumpAt > Const.CRIT_TIMEOUT * 2 then State.critJumpAt = now humanoid.Jump = true return elseif now - State.critJumpAt < Const.CRIT_TIMEOUT then return end end State.lastSwing = now State.auraRotate = true attackTarget(rootPart, entry.character) end ---Drag the camera onto the aura target every frame, after the game's own camera has run. updateAuraCamera = LPH_NO_VIRTUALIZE(function(deltaTime) if State.lookFn or not currentCamera then return end if State.busy and not (State.comboSequence and State.maceTarget) then return end local follow = Settings.cameraMode == 3 local maceTarget = State.maceTarget if maceTarget and not (follow or os.clock() < State.comboUntil) then maceTarget = nil end local character = maceTarget or (follow and State.auraTarget) if not (character and character.Parent) then return end if not maceTarget and not (Settings.killAura and Settings.killAuraFace) then return end local aimPart = getAuraAimPart(character) if not aimPart then return end -- A falling smash has no time to ease in, so the mace always snaps. local snap = (maceTarget and State.maceFalling) or Settings.auraDragSpeed >= 10 local alpha = snap and 1 or 1 - math.exp(-deltaTime * math.max(Settings.auraDragSpeed, 6) * 4) aimCamera(getPredictedPosition(aimPart, character), alpha) end) ---Track how far we've dropped since the highest point of this airtime. ---@param rootPart BasePart ---@param humanoid Humanoid ---@return number, boolean local function updateFall(rootPart, humanoid) local height = rootPart.Position.Y local grounded = humanoid.FloorMaterial ~= Enum.Material.Air if grounded or not State.fallPeak then State.fallPeak = height else State.fallPeak = math.max(State.fallPeak, height) end return State.fallPeak - height, grounded end ---Jump like the player would: humanoid jump plus the game's own Jump button if it listens to it. ---@param humanoid Humanoid local function pressJump(humanoid) humanoid.Jump = true local control = getControl("Jump") if control and isShown(control) and hasHandlers(control) then setControl(control, true) task.delay(Const.CLICK_HOLD, setControl, control, false) end end ---Frame-timed wind charge at the feet: throw then jump (default), or jump then throw in the air. ---Pass awayDirection to tilt the blast so it pushes us that way; armMace swaps to the mace mid-air. ---@param humanoid Humanoid ---@param armMace boolean? ---@param awayDirection Vector3? local function windLaunch(humanoid, armMace, awayDirection, tiltScale) runSequence(function(sleep) State.comboSequence = armMace and true or false local originalLook = currentCamera.CFrame.LookVector equipSlot(Settings.windSlot, sleep) local character = localPlayer.Character local rootPart = character and character:FindFirstChild("HumanoidRootPart") if not rootPart then return end -- Never throw the wrong item: if the game says this isn't the wind charge, relearn the hotbar. if not heldItemMatches("windSlot") then notify(string.format("Slot %d is %s, not a wind charge, rescanning", Settings.windSlot, getHeldItemName() or "?")) task.defer(scanHotbar, true) return end local flat = Vector3.new(originalLook.X, 0, originalLook.Z) flat = flat.Magnitude > 1e-3 and flat.Unit or Vector3.zAxis local tilt = awayDirection and -awayDirection * (tiltScale or 1.2) or flat * 0.05 local function feet() return rootPart.Position - Vector3.yAxis * 3 + tilt end local cursor = centerCursor() lookAt(feet) -- A throw before the view is down goes forward instead of at the feet; slower cameras (swipe aim) need a moment. local aimStart = os.clock() while getAimError(feet()) > Const.WIND_AIM_TOLERANCE and os.clock() - aimStart < Const.WIND_AIM_WAIT do runService.RenderStepped:Wait() end sleep(0) if Settings.windOrder == 1 then -- Throw at the feet, then jump as the burst goes off for the most height. tapUse() sleep(Const.WIND_JUMP_AFTER_THROW) pressJump(humanoid) else pressJump(humanoid) local start = os.clock() repeat sleep() until humanoid.FloorMaterial == Enum.Material.Air or os.clock() - start > Const.WIND_JUMP_TIMEOUT sleep(Const.WIND_THROW_DELAY) tapUse() end local thrownAt = os.clock() local bestRise = rootPart.AssemblyLinearVelocity.Y for _ = 1, Const.LOOK_SETTLE_FRAMES do runService.RenderStepped:Wait() end sleep(0) -- Air boost: throw more charges at the top of each rise for a bigger fall. for _ = 1, Settings.airBoostCharges do local start = os.clock() repeat sleep() until rootPart.AssemblyLinearVelocity.Y < Const.AIR_BOOST_APEX or os.clock() - start > Const.AIR_BOOST_TIMEOUT -- Already dropping: a late charge only delays the mace. if rootPart.AssemblyLinearVelocity.Y < -15 then break end lookAt(feet) sleep(0) tapUse() for _ = 1, Const.LOOK_SETTLE_FRAMES do runService.RenderStepped:Wait() end end releaseLook(originalLook) restoreCursor(cursor) -- Swap while still rising so the mace is ready before the drop. if armMace then equipSlot(Settings.maceSlot, sleep) State.maceArmed, State.maceSwung = true, false -- Slow equips eat into the smash window, so it starts counting from here. State.comboUntil = math.max(State.comboUntil, os.clock() + 2) if not heldItemMatches("maceSlot") then notify(string.format("Slot %d is %s, not a mace", Settings.maceSlot, getHeldItemName() or "?")) end else equipSlot(Settings.swordSlot, sleep) end -- Tell the player when the blast didn't lift them; runs on the side so the smash isn't held up. task.spawn(function() while os.clock() - thrownAt < Const.LAUNCH_CHECK_TIME do bestRise = math.max(bestRise, rootPart.AssemblyLinearVelocity.Y) if bestRise >= Const.LAUNCH_MIN_RISE then return end task.wait() end if os.clock() - State.launchWarnedAt > 30 then State.launchWarnedAt = os.clock() notify(State.cameraDriver and "Wind didn't launch you, try Input Mode" or "Wind didn't launch, camera not synced yet") end end) end) end ---Wind charge launch then mace smash on the nearest target, on demand (button or keybind). function comboSmash() -- Spam taps queue nothing; one tap starts one combo. local now = os.clock() if now - State.smashTapAt < Const.SMASH_TAP_DEBOUNCE then return end State.smashTapAt = now local character = localPlayer.Character local humanoid = character and character:FindFirstChildOfClass("Humanoid") if not humanoid or humanoid.Health <= 0 then return end if State.busy then notify("Busy, tap SMASH again in a moment") return end if State.missingItems.windSlot then notify("No wind charge in this kit") return end State.comboUntil = now + 3 State.lastWind = now windLaunch(humanoid, true) end ---Wind dash: blast behind our feet to fly forward the way the camera faces. function windDash() local character = localPlayer.Character local humanoid = character and character:FindFirstChildOfClass("Humanoid") if not humanoid or humanoid.Health <= 0 or State.busy then return end if State.missingItems.windSlot then notify("No wind charge in this kit") return end local look = currentCamera.CFrame.LookVector local flat = Vector3.new(look.X, 0, look.Z) windLaunch(humanoid, false, flat.Magnitude > 1e-3 and flat.Unit or Vector3.zAxis, Const.DASH_TILT) end ---Whether we'll touch the ground (or the target) within the lookahead window. ---@param rootPart BasePart ---@param velocity Vector3 ---@return boolean local function isLandingSoon(rootPart, velocity) local drop = math.max(-velocity.Y * Const.MACE_LANDING_LOOKAHEAD, 0) + rootPart.Size.Y / 2 + 3.2 raycastParams.FilterDescendantsInstances = { currentCamera, localPlayer.Character } return workspace:Raycast(rootPart.Position, Vector3.new