Playermover v13
Key RequiredUniversal

Playermover v13

Universal Scriptreverb0012reverb0012 546 views 312 executesUpdated Jan 31, 2026
Unrated
00
Lua Script•1521 lines (87717 chars)
-- LocalScript (StarterGui)
-- PlayerMover v13 — Universal Above + full keybinds
-- Drop into StarterGui

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local TeamsService = game:GetService("Teams")
local UserInputService = game:GetService("UserInputService")

local LocalPlayer = Players.LocalPlayer
local Workspace = workspace

-- Defaults
local DEFAULT_CFRAME_WALK_SPEED = 1    -- studs/frame
local DEFAULT_BV_SPEED = 6             -- studs/sec
local DEFAULT_PRED = 0.12
local DEFAULT_LOOK_PRED = 0.12
local DEFAULT_LOOKV2_PRED = 0.12
local DEFAULT_ABOVE_TWEEN = 0.05

local STUCK_TIME_THRESHOLD = 1.2
local STUCK_MOVE_EPS = 0.12
local COLLIDE_MIN_DIST = 0.75

-- State
local selectedPlayer = nil
local cframeWalkActive = false
local universalForwardActive = false
local universalWalkToPlayersActive = false
local flyActive = false
local universalAutoFly = false
local aboveActive = false
local universalAboveActive = false

local lookActive = false
local lookV2Active = false
local universalLook = false
local universalLookV2 = false

local uniCFrameMode = "Normal"
local uniFlyMode = "Normal"
local uniOffset = 2
local uniMixWalkMode = "Normal"
local uniMixFlyMode = "Normal"

local bv, bg, ctrlRootPart = nil, nil, nil
local playerState = {} -- per-player pos/vel/t
local lastMyPos, lastMovedAt = nil, tick()

-- Team / NPC settings
local teamCheckEnabled = false     -- do not target own team
local teamSelected = nil           -- Team instance selected via team finder
local teamOnlyTarget = false       -- only target players on that team
local lookAtNPCsBeta = false       -- when true, universal LookAt / LookAtV2 will target NPC models

-- Keybinds (stored uppercase, no spaces)
local lookKey = ""
local lookV2Key = ""
local uniLookKey = ""
local uniLookV2Key = ""
local cwalkKey = ""           -- CFrame Walk (target)
local uniForwardKey = ""      -- Universal forward
local uniToPlayersKey = ""    -- Universal Walk-To-Nearest key
local uniAutoFlyKey = ""      -- Universal AutoFly key
local flyKey = ""             -- Fly to selected key
local aboveKey = ""           -- Above (selected) key
local uniAboveKey = ""        -- Universal Above key

local typingInTextBox = false -- prevents keybind firing while user is editing

-- Helpers
local function safeChar(plr) return (plr and plr.Character) and plr.Character or nil end

local function bestPart(plr)
    local ch = safeChar(plr)
    if not ch then return nil end
    return ch:FindFirstChild("HumanoidRootPart") or ch:FindFirstChild("UpperTorso")
       or ch:FindFirstChild("Torso") or ch:FindFirstChild("Head")
end

local function isAlive(plr)
    local ch = safeChar(plr)
    if not ch then return false end
    local hum = ch:FindFirstChildOfClass("Humanoid")
    return hum and hum.Health and hum.Health > 0
end

-- Update per-player states for prediction
local function updatePlayerState(plr, now)
    local part = bestPart(plr)
    if not playerState[plr] then playerState[plr] = {pos = nil, vel = Vector3.new(0,0,0), t = now} end
    local st = playerState[plr]
    if not part then
        st.pos = nil; st.vel = Vector3.new(0,0,0); st.t = now
        return
    end
    local cur = part.Position
    if st.pos and st.t then
        local dt = math.max(1e-4, now - st.t)
        st.vel = (cur - st.pos) / dt
    else
        st.vel = Vector3.new(0,0,0)
    end
    st.pos = cur
    st.t = now
end

local function predictedPosition(plr, predSecs)
    if typeof(plr) == "Instance" and plr:IsA("Model") and plr:FindFirstChildOfClass("Humanoid") then
        local hrp = plr:FindFirstChild("HumanoidRootPart") or plr:FindFirstChild("UpperTorso") or plr:FindFirstChild("Torso")
        if hrp then
            local st = playerState[plr]
            if st and st.pos and st.vel and predSecs and predSecs > 0 then
                return hrp.Position + st.vel * predSecs
            end
            return hrp.Position
        end
        return nil
    end

    local part = bestPart(plr)
    if not part then return nil end
    local st = playerState[plr]
    if st and st.pos and st.vel and predSecs and predSecs > 0 then
        return part.Position + st.vel * predSecs
    end
    return part.Position
end

local function isPositionCollidingWithPlayers(pos)
    if not pos then return false end
    for _,p in ipairs(Players:GetPlayers()) do
        if p ~= LocalPlayer then
            local pr = bestPart(p)
            if pr and pr.Position and (pos - pr.Position).Magnitude < COLLIDE_MIN_DIST then
                return true
            end
        end
    end
    return false
end

-- Find nearest *player* to me respecting team settings
local function getNearestAlivePlayerToMe()
    local myChar = LocalPlayer.Character
    local myRoot = myChar and (myChar:FindFirstChild("HumanoidRootPart") or myChar:FindFirstChild("UpperTorso") or myChar:FindFirstChild("Torso"))
    if not myRoot then return nil end
    local best, bestDist = nil, math.huge
    for _,p in ipairs(Players:GetPlayers()) do
        if p ~= LocalPlayer and isAlive(p) then
            if teamOnlyTarget then
                if teamSelected and p.Team ~= teamSelected then
                    -- skip
                else
                    local pr = bestPart(p)
                    if pr then
                        local d = (pr.Position - myRoot.Position).Magnitude
                        if d < bestDist then bestDist = d; best = p end
                    end
                end
            else
                -- teamCheck: if enabled skip same team
                if teamCheckEnabled and LocalPlayer.Team and p.Team and LocalPlayer.Team == p.Team then
                    -- skip same team
                else
                    local pr = bestPart(p)
                    if pr then
                        local d = (pr.Position - myRoot.Position).Magnitude
                        if d < bestDist then bestDist = d; best = p end
                    end
                end
            end
        end
    end
    return best
end

-- Find nearest NPC model
local function getNearestNPCToMe()
    local myChar = LocalPlayer.Character
    local myRoot = myChar and (myChar:FindFirstChild("HumanoidRootPart") or myChar:FindFirstChild("UpperTorso") or myChar:FindFirstChild("Torso"))
    if not myRoot then return nil end
    local best, bestDist = nil, math.huge
    for _,obj in ipairs(Workspace:GetDescendants()) do
        if obj:IsA("Model") and obj:FindFirstChildOfClass("Humanoid") then
            local isPlayerChar = false
            for _,pl in ipairs(Players:GetPlayers()) do
                if pl.Character == obj then isPlayerChar = true; break end
            end
            if not isPlayerChar then
                local hrp = obj:FindFirstChild("HumanoidRootPart") or obj:FindFirstChild("UpperTorso") or obj:FindFirstChild("Torso")
                if hrp then
                    local d = (hrp.Position - myRoot.Position).Magnitude
                    if d < bestDist then bestDist = d; best = obj end
                end
            end
        end
    end
    return best
end

-- BV controllers
local function ensureControllers()
    local char = LocalPlayer.Character
    if not char then return end
    local root = char:FindFirstChild("HumanoidRootPart") or char:FindFirstChild("UpperTorso") or char:FindFirstChild("Torso")
    if not root then return end
    ctrlRootPart = root
    if not bg or not bg.Parent then
        bg = Instance.new("BodyGyro"); bg.Name = "PMv13_BodyGyro"; bg.P = 9e4; bg.D = 500
        bg.MaxTorque = Vector3.new(9e9,9e9,9e9); bg.CFrame = root.CFrame; bg.Parent = root
    end
    if not bv or not bv.Parent then
        bv = Instance.new("BodyVelocity"); bv.Name = "PMv13_BodyVelocity"
        bv.MaxForce = Vector3.new(9e9,9e9,9e9); bv.Velocity = Vector3.new(0,0,0); bv.Parent = root
    end
end

local function removeControllers()
    if bv then pcall(function() bv:Destroy() end) end
    if bg then pcall(function() bg:Destroy() end) end
    bv, bg, ctrlRootPart = nil, nil, nil
end

-- computeOffsetTarget (reused)
local function computeOffsetTarget(plr, mode, offset, forFly, predSecs)
    if not plr then return nil end
    local tgtPart = nil
    if typeof(plr) == "Instance" and plr:IsA("Model") and plr:FindFirstChildOfClass("Humanoid") then
        tgtPart = plr:FindFirstChild("HumanoidRootPart") or plr:FindFirstChild("UpperTorso") or plr:FindFirstChild("Torso") or plr:FindFirstChild("Head")
    else
        tgtPart = bestPart(plr)
    end
    if not tgtPart then return nil end
    predSecs = predSecs or (tonumber(walkPredBox and walkPredBox.Text or tostring(DEFAULT_PRED)) or DEFAULT_PRED)
    local basePos = predictedPosition(plr, predSecs) or (tgtPart.Position)
    local ok, tgtCFrame = pcall(function() return (tgtPart.CFrame) end)
    local look = ok and tgtCFrame.LookVector or Vector3.new(0,0,1)
    offset = tonumber(offset or 0) or 0

    if mode == "Normal" or offset <= 0 then
        if forFly then
            return basePos
        else
            local hrp = LocalPlayer.Character and (LocalPlayer.Character:FindFirstChild("HumanoidRootPart") or LocalPlayer.Character:FindFirstChild("UpperTorso") or LocalPlayer.Character:FindFirstChild("Torso"))
            if hrp then return Vector3.new(basePos.X, hrp.Position.Y, basePos.Z) end
            return basePos
        end
    end

    local dir = Vector3.new(look.X, (forFly and look.Y or 0), look.Z)
    if dir.Magnitude < 1e-6 then dir = Vector3.new(0,0,1) end

    local desired
    if mode == "Behind" then desired = basePos - dir.Unit * offset
    else desired = basePos + dir.Unit * offset end

    local toDesiredXZ = Vector3.new(desired.X - basePos.X, 0, desired.Z - basePos.Z)
    local distXZ = toDesiredXZ.Magnitude
    if distXZ < offset - 1e-4 then
        local fromMe = LocalPlayer.Character and (LocalPlayer.Character:FindFirstChild("HumanoidRootPart") or LocalPlayer.Character:FindFirstChild("UpperTorso") or LocalPlayer.Character:FindFirstChild("Torso"))
        local angleVec
        if fromMe then
            angleVec = Vector3.new(fromMe.Position.X - basePos.X, 0, fromMe.Position.Z - basePos.Z)
            if angleVec.Magnitude < 1e-4 then angleVec = Vector3.new(1,0,0) end
        else
            angleVec = Vector3.new(desired.X - basePos.X, 0, desired.Z - basePos.Z)
            if angleVec.Magnitude < 1e-4 then angleVec = Vector3.new(1,0,0) end
        end
        local perimeterXZ = basePos + angleVec.Unit * offset
        if forFly then
            desired = Vector3.new(perimeterXZ.X, desired.Y, perimeterXZ.Z)
        else
            local hrp = LocalPlayer.Character and (LocalPlayer.Character:FindFirstChild("HumanoidRootPart") or LocalPlayer.Character:FindFirstChild("UpperTorso") or LocalPlayer.Character:FindFirstChild("Torso"))
            local y = hrp and hrp.Position.Y or basePos.Y
            desired = Vector3.new(perimeterXZ.X, y, perimeterXZ.Z)
        end
    end

    if isPositionCollidingWithPlayers(desired) then
        desired = desired + Vector3.new(0, 1.2, 0)
    end
    return desired
end

-- Movement helpers (cframe step & forward)
local function cframeStepTowardsExact(hrp, targetPos, stepDist)
    if not (hrp and hrp:IsA("BasePart")) or not targetPos then return end
    local from = hrp.Position
    local dir = targetPos - from
    local dist = dir.Magnitude
    if dist <= 0.001 then return end
    local step = tonumber(stepDist) or DEFAULT_CFRAME_WALK_SPEED
    if step <= 0 then return end
    local t = math.min(1, step / dist)
    local newPos = from:Lerp(targetPos, t)
    if (targetPos - newPos).Magnitude < 0.6 then
        local offset = from - targetPos
        if offset.Magnitude < 0.0001 then offset = Vector3.new(1,0,0) end
        offset = offset.Unit
        newPos = targetPos + offset * 1.1
    end
    if isPositionCollidingWithPlayers(newPos) then
        local nearest, nd = nil, math.huge
        for _,p in ipairs(Players:GetPlayers()) do
            if p ~= LocalPlayer then
                local pr = bestPart(p)
                if pr then
                    local d = (newPos - pr.Position).Magnitude
                    if d < nd then nd = d; nearest = pr end
                end
            end
        end
        if nearest then
            local away = newPos - nearest.Position
            if away.Magnitude < 0.001 then away = Vector3.new(1,0,0) end
            newPos = nearest.Position + away.Unit * (COLLIDE_MIN_DIST + 0.4)
        end
    end
    local look = hrp.CFrame.LookVector
    local newCf = CFrame.new(newPos, newPos + look)
    pcall(function() hrp.CFrame = newCf end)
end

local function cframeMoveForwardHorizontalExact_ByHRP(hrp, stepDist)
    if not (hrp and hrp:IsA("BasePart")) then return end
    local from = hrp.Position
    local horiz = Vector3.new(hrp.CFrame.LookVector.X, 0, hrp.CFrame.LookVector.Z)
    if horiz.Magnitude < 1e-6 then return end
    local step = tonumber(stepDist) or DEFAULT_CFRAME_WALK_SPEED
    if step <= 0 then return end
    local newPos = from + horiz.Unit * step
    if isPositionCollidingWithPlayers(newPos) then newPos = newPos + Vector3.new(0,1.2,0) end
    local newCf = CFrame.new(newPos, newPos + horiz.Unit)
    pcall(function() hrp.CFrame = newCf end)
end

local function flyTowardPositionBV(destPos, speed)
    if not destPos then return end
    ensureControllers()
    if not ctrlRootPart or not bg or not bv then return end
    local myPos = ctrlRootPart.Position
    local to = destPos - myPos
    local dist = to.Magnitude
    if dist < 0.2 then bv.Velocity = Vector3.new(0,0,0) else
        local dir = to.Unit
        local v = dir * (tonumber(speed) or DEFAULT_BV_SPEED)
        bv.Velocity = v
    end
    bg.CFrame = CFrame.new(ctrlRootPart.Position, destPos)
end

-- Look helpers
local function doLookAtPositionXY(pos)
    if not pos then return end
    local ch = LocalPlayer.Character
    local hrp = ch and (ch:FindFirstChild("HumanoidRootPart") or ch:FindFirstChild("UpperTorso") or ch:FindFirstChild("Torso"))
    if not hrp then return end
    local myPos = hrp.Position
    local targetPos = Vector3.new(pos.X, myPos.Y, pos.Z)
    pcall(function() hrp.CFrame = CFrame.new(myPos, targetPos) end)
end
local function doLookAtPositionV2(pos, rollDeg)
    if not pos then return end
    local ch = LocalPlayer.Character
    local hrp = ch and (ch:FindFirstChild("HumanoidRootPart") or ch:FindFirstChild("UpperTorso") or ch:FindFirstChild("Torso"))
    if not hrp then return end
    local base = CFrame.new(hrp.Position, pos)
    local roll = CFrame.Angles(0,0,math.rad(tonumber(rollDeg) or 0))
    pcall(function() hrp.CFrame = base * roll end)
end

-- UI build (PlayerMover v13)
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "PlayerMoverGui_v13"
screenGui.ResetOnSpawn = false
screenGui.Parent = LocalPlayer:WaitForChild("PlayerGui")

local main = Instance.new("Frame", screenGui)
main.Name = "Main"
main.Size = UDim2.new(0,700,0,700)
main.Position = UDim2.new(0.02,0,0.04,0)
main.BackgroundColor3 = Color3.fromRGB(20,20,22)
main.BorderSizePixel = 0
main.Active = true

local header = Instance.new("Frame", main)
header.Size = UDim2.new(1,0,0,44)
header.BackgroundColor3 = Color3.fromRGB(34,34,36)

local title = Instance.new("TextLabel", header)
title.Position = UDim2.new(0,12,0,6)
title.Size = UDim2.new(0.6,-24,1,-12)
title.BackgroundTransparency = 1
title.Text = "PlayerMover v13 (Universal Above + keybinds)"
title.TextColor3 = Color3.fromRGB(240,240,240)
title.Font = Enum.Font.GothamBold
title.TextSize = 16
title.TextXAlignment = Enum.TextXAlignment.Left

local closeBtn = Instance.new("TextButton", header)
closeBtn.Size = UDim2.new(0,40,0,28)
closeBtn.Position = UDim2.new(1,-52,0.5,-14)
closeBtn.Text = "X"
closeBtn.Font = Enum.Font.Gotham
closeBtn.TextColor3 = Color3.new(1,1,1)
closeBtn.BackgroundColor3 = Color3.fromRGB(160,46,46)
closeBtn.BorderSizePixel = 0

-- Tabs (3)
local tabBar = Instance.new("Frame", main)
tabBar.Size = UDim2.new(1,-16,0,36)
tabBar.Position = UDim2.new(0,8,0,52)
tabBar.BackgroundTransparency = 1

local t1 = Instance.new("TextButton", tabBar)
t1.Size = UDim2.new(0.333,-6,1,0); t1.Position = UDim2.new(0,0,0,0); t1.Text = "Main"; t1.Font = Enum.Font.Gotham; t1.TextSize = 14; t1.BackgroundColor3 = Color3.fromRGB(60,60,60)
local t2 = Instance.new("TextButton", tabBar)
t2.Size = UDim2.new(0.333,-6,1,0); t2.Position = UDim2.new(0.333,4,0,0); t2.Text = "Universal"; t2.Font = Enum.Font.Gotham; t2.TextSize = 14; t2.BackgroundColor3 = Color3.fromRGB(36,36,40)
local t3 = Instance.new("TextButton", tabBar)
t3.Size = UDim2.new(0.333,-6,1,0); t3.Position = UDim2.new(0.666,8,0,0); t3.Text = "Team"; t3.Font = Enum.Font.Gotham; t3.TextSize = 14; t3.BackgroundColor3 = Color3.fromRGB(36,36,40)

-- Pages
local pageMain = Instance.new("Frame", main)
pageMain.Size = UDim2.new(1,-16,1,-200); pageMain.Position = UDim2.new(0,8,0,96); pageMain.BackgroundTransparency = 1

local pageUni = Instance.new("Frame", main)
pageUni.Size = pageMain.Size; pageUni.Position = pageMain.Position; pageUni.BackgroundTransparency = 1; pageUni.Visible = false

local pageTeam = Instance.new("Frame", main)
pageTeam.Size = pageMain.Size; pageTeam.Position = pageMain.Position; pageTeam.BackgroundTransparency = 1; pageTeam.Visible = false

-- Player list (Main)
local listFrame = Instance.new("Frame", pageMain)
listFrame.Size = UDim2.new(0.44,0,1,0); listFrame.BackgroundColor3 = Color3.fromRGB(26,26,28)
local listTitle = Instance.new("TextLabel", listFrame); listTitle.Size = UDim2.new(1,0,0,28); listTitle.BackgroundTransparency = 1; listTitle.Font = Enum.Font.GothamBold; listTitle.TextSize = 14; listTitle.TextColor3 = Color3.fromRGB(230,230,230); listTitle.Text = "Players"

local playerScroll = Instance.new("ScrollingFrame", listFrame)
playerScroll.Position = UDim2.new(0,8,0,36); playerScroll.Size = UDim2.new(1,-16,1,-44); playerScroll.BackgroundTransparency = 1; playerScroll.ScrollBarThickness = 6
local listLayout = Instance.new("UIListLayout", playerScroll); listLayout.Padding = UDim.new(0,6); listLayout.SortOrder = Enum.SortOrder.LayoutOrder

-- Controls main
local ctrl = Instance.new("Frame", pageMain)
ctrl.Size = UDim2.new(0.54,0,1,0); ctrl.Position = UDim2.new(0.46,8,0,0); ctrl.BackgroundTransparency = 1

local selLabel = Instance.new("TextLabel", ctrl)
selLabel.Position = UDim2.new(0,8,0,6); selLabel.Size = UDim2.new(1,-16,0,22); selLabel.BackgroundTransparency = 1; selLabel.Font = Enum.Font.Gotham; selLabel.TextSize = 14; selLabel.TextColor3 = Color3.fromRGB(220,220,220); selLabel.Text = "Selected: <none>"

-- walk speed + pred
local walkSpeedLbl = Instance.new("TextLabel", ctrl)
walkSpeedLbl.Position = UDim2.new(0,8,0,36); walkSpeedLbl.Size = UDim2.new(0,260,0,18); walkSpeedLbl.BackgroundTransparency = 1; walkSpeedLbl.Font = Enum.Font.Gotham; walkSpeedLbl.Text = "CFrame Walk Speed (studs/frame):"
local walkSpeedBox = Instance.new("TextBox", ctrl); walkSpeedBox.Position = UDim2.new(0,270,0,32); walkSpeedBox.Size = UDim2.new(0,96,0,26); walkSpeedBox.Text = tostring(DEFAULT_CFRAME_WALK_SPEED); walkSpeedBox.ClearTextOnFocus = false; walkSpeedBox.Font = Enum.Font.Gotham

local predLbl = Instance.new("TextLabel", ctrl)
predLbl.Position = UDim2.new(0,8,0,68); predLbl.Size = UDim2.new(0,200,0,18); predLbl.BackgroundTransparency = 1; predLbl.Font = Enum.Font.Gotham; predLbl.Text = "Prediction (s) for Walk/Fly (shared):"
local walkPredBox = Instance.new("TextBox", ctrl); walkPredBox.Position = UDim2.new(0,210,0,64); walkPredBox.Size = UDim2.new(0,96,0,26); walkPredBox.Text = tostring(DEFAULT_PRED); walkPredBox.ClearTextOnFocus = false; walkPredBox.Font = Enum.Font.Gotham

-- look preds (separate)
local lookPredLbl = Instance.new("TextLabel", ctrl)
lookPredLbl.Position = UDim2.new(0,8,0,100); lookPredLbl.Size = UDim2.new(0,240,0,18); lookPredLbl.BackgroundTransparency = 1; lookPredLbl.Font = Enum.Font.Gotham; lookPredLbl.Text = "LookAt prediction (s) — LookAt (XY):"
local lookPredBox = Instance.new("TextBox", ctrl); lookPredBox.Position = UDim2.new(0,260,0,96); lookPredBox.Size = UDim2.new(0,96,0,26); lookPredBox.Text = tostring(DEFAULT_LOOK_PRED); lookPredBox.ClearTextOnFocus = false; lookPredBox.Font = Enum.Font.Gotham

local lookV2PredLbl = Instance.new("TextLabel", ctrl)
lookV2PredLbl.Position = UDim2.new(0,8,0,132); lookV2PredLbl.Size = UDim2.new(0,240,0,18); lookV2PredLbl.BackgroundTransparency = 1; lookV2PredLbl.Font = Enum.Font.Gotham; lookV2PredLbl.Text = "LookAtV2 prediction (s) — LookAtV2 (XYZ):"
local lookV2PredBox = Instance.new("TextBox", ctrl); lookV2PredBox.Position = UDim2.new(0,260,0,128); lookV2PredBox.Size = UDim2.new(0,96,0,26); lookV2PredBox.Text = tostring(DEFAULT_LOOKV2_PRED); lookV2PredBox.ClearTextOnFocus = false; lookV2PredBox.Font = Enum.Font.Gotham

-- CFrame walk and Fly
local cwalkBtn = Instance.new("TextButton", ctrl); cwalkBtn.Position = UDim2.new(0,8,0,168); cwalkBtn.Size = UDim2.new(0,240,0,36); cwalkBtn.Text = "CFrame Walk (to selected): OFF"; cwalkBtn.Font = Enum.Font.Gotham; cwalkBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)

-- CWalk keybox (main page)
local cwalkKeyBox = Instance.new("TextBox", ctrl)
cwalkKeyBox.Position = UDim2.new(0,260,0,168)
cwalkKeyBox.Size = UDim2.new(0,96,0,36)
cwalkKeyBox.Text = ""
cwalkKeyBox.PlaceholderText = "Key"
cwalkKeyBox.ClearTextOnFocus = false
cwalkKeyBox.Font = Enum.Font.Gotham
cwalkKeyBox.BackgroundTransparency = 0.6 -- slightly transparent

local flySpeedLbl = Instance.new("TextLabel", ctrl); flySpeedLbl.Position = UDim2.new(0,8,0,216); flySpeedLbl.Size = UDim2.new(0,220,0,18); flySpeedLbl.BackgroundTransparency = 1; flySpeedLbl.Font = Enum.Font.Gotham; flySpeedLbl.Text = "Fly BV Speed (studs/sec):"
local flySpeedBox = Instance.new("TextBox", ctrl); flySpeedBox.Position = UDim2.new(0,230,0,212); flySpeedBox.Size = UDim2.new(0,96,0,26); flySpeedBox.Text = tostring(DEFAULT_BV_SPEED); flySpeedBox.ClearTextOnFocus = false; flySpeedBox.Font = Enum.Font.Gotham
local flyPredLbl = Instance.new("TextLabel", ctrl); flyPredLbl.Position = UDim2.new(0,8,0,252); flyPredLbl.Size = UDim2.new(0,160,0,18); flyPredLbl.BackgroundTransparency = 1; flyPredLbl.Font = Enum.Font.Gotham; flyPredLbl.Text = "Fly Prediction (s):"
local flyPredBox = Instance.new("TextBox", ctrl); flyPredBox.Position = UDim2.new(0,170,0,248); flyPredBox.Size = UDim2.new(0,96,0,26); flyPredBox.Text = tostring(DEFAULT_PRED); flyPredBox.ClearTextOnFocus = false; flyPredBox.Font = Enum.Font.Gotham

local flyBtn = Instance.new("TextButton", ctrl); flyBtn.Position = UDim2.new(0,8,0,288); flyBtn.Size = UDim2.new(0,240,0,36); flyBtn.Text = "Fly (BV to selected): OFF"; flyBtn.Font = Enum.Font.Gotham; flyBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)

-- Fly keybox
local flyKeyBox = Instance.new("TextBox", ctrl)
flyKeyBox.Position = UDim2.new(0,260,0,288)
flyKeyBox.Size = UDim2.new(0,96,0,36)
flyKeyBox.Text = ""
flyKeyBox.PlaceholderText = "Key"
flyKeyBox.ClearTextOnFocus = false
flyKeyBox.Font = Enum.Font.Gotham
flyKeyBox.BackgroundTransparency = 0.6

-- Above
local aboveLbl = Instance.new("TextLabel", ctrl); aboveLbl.Position = UDim2.new(0,8,0,332); aboveLbl.Size = UDim2.new(0,160,0,18); aboveLbl.BackgroundTransparency = 1; aboveLbl.Font = Enum.Font.Gotham; aboveLbl.Text = "Above height (studs):"
local aboveBox = Instance.new("TextBox", ctrl); aboveBox.Position = UDim2.new(0,170,0,328); aboveBox.Size = UDim2.new(0,96,0,26); aboveBox.Text = "8"; aboveBox.ClearTextOnFocus = false; aboveBox.Font = Enum.Font.Gotham
local aboveTweenLbl = Instance.new("TextLabel", ctrl); aboveTweenLbl.Position = UDim2.new(0,8,0,364); aboveTweenLbl.Size = UDim2.new(0,160,0,18); aboveTweenLbl.BackgroundTransparency = 1; aboveTweenLbl.Font = Enum.Font.Gotham; aboveTweenLbl.Text = "Above tween time (s):"
local aboveTweenBox = Instance.new("TextBox", ctrl); aboveTweenBox.Position = UDim2.new(0,170,0,360); aboveTweenBox.Size = UDim2.new(0,96,0,26); aboveTweenBox.Text = tostring(DEFAULT_ABOVE_TWEEN); aboveTweenBox.ClearTextOnFocus = false; aboveTweenBox.Font = Enum.Font.Gotham
local aboveBtn = Instance.new("TextButton", ctrl); aboveBtn.Position = UDim2.new(0,280,0,328); aboveBtn.Size = UDim2.new(0,160,0,58); aboveBtn.Text = "Above: OFF"; aboveBtn.Font = Enum.Font.Gotham; aboveBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)

-- Above keybox
local aboveKeyBox = Instance.new("TextBox", ctrl)
aboveKeyBox.Position = UDim2.new(0,452,0,328)
aboveKeyBox.Size = UDim2.new(0,84,0,36)
aboveKeyBox.Text = ""
aboveKeyBox.PlaceholderText = "Key"
aboveKeyBox.ClearTextOnFocus = false
aboveKeyBox.Font = Enum.Font.Gotham
aboveKeyBox.BackgroundTransparency = 0.6

-- Look toggles + keybind boxes (Main page)
local lookBtn = Instance.new("TextButton", ctrl); lookBtn.Position = UDim2.new(0,8,0,428); lookBtn.Size = UDim2.new(0,160,0,34); lookBtn.Text = "LookAt (XY): OFF"; lookBtn.Font = Enum.Font.Gotham
local lookKeyBox = Instance.new("TextBox", ctrl); lookKeyBox.Position = UDim2.new(0,176,0,428); lookKeyBox.Size = UDim2.new(0,72,0,34); lookKeyBox.Text = ""; lookKeyBox.PlaceholderText = "Key"; lookKeyBox.ClearTextOnFocus = false; lookKeyBox.Font = Enum.Font.Gotham; lookKeyBox.BackgroundTransparency = 0.6

local lookV2Btn = Instance.new("TextButton", ctrl); lookV2Btn.Position = UDim2.new(0,260,0,428); lookV2Btn.Size = UDim2.new(0,240,0,34); lookV2Btn.Text = "LookAtV2 (XYZ+Roll): OFF"; lookV2Btn.Font = Enum.Font.Gotham
local lookV2KeyBox = Instance.new("TextBox", ctrl); lookV2KeyBox.Position = UDim2.new(0,508,0,428); lookV2KeyBox.Size = UDim2.new(0,72,0,34); lookV2KeyBox.Text = ""; lookV2KeyBox.PlaceholderText = "Key"; lookV2KeyBox.ClearTextOnFocus = false; lookV2KeyBox.Font = Enum.Font.Gotham; lookV2KeyBox.BackgroundTransparency = 0.6

-- Universal page
local uniTitle = Instance.new("TextLabel", pageUni); uniTitle.Position = UDim2.new(0,8,0,8); uniTitle.Size = UDim2.new(1,-16,0,22); uniTitle.BackgroundTransparency = 1; uniTitle.Font = Enum.Font.GothamBold; uniTitle.Text = "Universal Controls (Combat & Mix Modes)"

local uniForwardBtn = Instance.new("TextButton", pageUni); uniForwardBtn.Position = UDim2.new(0,8,0,44); uniForwardBtn.Size = UDim2.new(0,360,0,40); uniForwardBtn.Text = "Universal Forward CFrame-Walk (HRP facing): OFF"; uniForwardBtn.Font = Enum.Font.Gotham; uniForwardBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)

-- universal forward keybox
local uniForwardKeyBox = Instance.new("TextBox", pageUni)
uniForwardKeyBox.Position = UDim2.new(0,380,0,44)
uniForwardKeyBox.Size = UDim2.new(0,84,0,40)
uniForwardKeyBox.Text = ""
uniForwardKeyBox.PlaceholderText = "Key"
uniForwardKeyBox.ClearTextOnFocus = false
uniForwardKeyBox.Font = Enum.Font.Gotham
uniForwardKeyBox.BackgroundTransparency = 0.6

local uniToPlayersBtn = Instance.new("TextButton", pageUni); uniToPlayersBtn.Position = UDim2.new(0,8,0,104); uniToPlayersBtn.Size = UDim2.new(0,360,0,40); uniToPlayersBtn.Text = "Universal Walk-To-Nearest Player: OFF"; uniToPlayersBtn.Font = Enum.Font.Gotham; uniToPlayersBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
-- uniToPlayers keybox
local uniToPlayersKeyBox = Instance.new("TextBox", pageUni)
uniToPlayersKeyBox.Position = UDim2.new(0,380,0,104)
uniToPlayersKeyBox.Size = UDim2.new(0,84,0,40)
uniToPlayersKeyBox.Text = ""
uniToPlayersKeyBox.PlaceholderText = "Key"
uniToPlayersKeyBox.ClearTextOnFocus = false
uniToPlayersKeyBox.Font = Enum.Font.Gotham
uniToPlayersKeyBox.BackgroundTransparency = 0.6

local uniAutoFlyBtn = Instance.new("TextButton", pageUni); uniAutoFlyBtn.Position = UDim2.new(0,8,0,164); uniAutoFlyBtn.Size = UDim2.new(0,360,0,40); uniAutoFlyBtn.Text = "Universal AutoFly (BV to nearest): OFF"; uniAutoFlyBtn.Font = Enum.Font.Gotham; uniAutoFlyBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
-- uniAutoFly keybox
local uniAutoFlyKeyBox = Instance.new("TextBox", pageUni)
uniAutoFlyKeyBox.Position = UDim2.new(0,380,0,164)
uniAutoFlyKeyBox.Size = UDim2.new(0,84,0,40)
uniAutoFlyKeyBox.Text = ""
uniAutoFlyKeyBox.PlaceholderText = "Key"
uniAutoFlyKeyBox.ClearTextOnFocus = false
uniAutoFlyKeyBox.Font = Enum.Font.Gotham
uniAutoFlyKeyBox.BackgroundTransparency = 0.6

-- Universal Above (new)
local uniAboveBtn = Instance.new("TextButton", pageUni)
uniAboveBtn.Position = UDim2.new(0,8,0,224)
uniAboveBtn.Size = UDim2.new(0,360,0,40)
uniAboveBtn.Text = "Universal Above (nearest): OFF"
uniAboveBtn.Font = Enum.Font.Gotham
uniAboveBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)

local uniAboveKeyBox = Instance.new("TextBox", pageUni)
uniAboveKeyBox.Position = UDim2.new(0,380,0,224)
uniAboveKeyBox.Size = UDim2.new(0,84,0,40)
uniAboveKeyBox.Text = ""
uniAboveKeyBox.PlaceholderText = "Key"
uniAboveKeyBox.ClearTextOnFocus = false
uniAboveKeyBox.Font = Enum.Font.Gotham
uniAboveKeyBox.BackgroundTransparency = 0.6

local cframeModeLabel = Instance.new("TextLabel", pageUni); cframeModeLabel.Position = UDim2.new(0,380,0,48); cframeModeLabel.Size = UDim2.new(0,260,0,20); cframeModeLabel.BackgroundTransparency = 1; cframeModeLabel.Font = Enum.Font.GothamBold; cframeModeLabel.Text = "CFrame Mode (walk-to-player):"
local cNormalBtn = Instance.new("TextButton", pageUni); cNormalBtn.Position = UDim2.new(0,380,0,72); cNormalBtn.Size = UDim2.new(0,84,0,32); cNormalBtn.Text = "Normal"
local cBehindBtn = Instance.new("TextButton", pageUni); cBehindBtn.Position = UDim2.new(0,472,0,72); cBehindBtn.Size = UDim2.new(0,84,0,32); cBehindBtn.Text = "Behind"
local cFrontBtn = Instance.new("TextButton", pageUni); cFrontBtn.Position = UDim2.new(0,564,0,72); cFrontBtn.Size = UDim2.new(0,84,0,32); cFrontBtn.Text = "Front"

local flyModeLabel = Instance.new("TextLabel", pageUni); flyModeLabel.Position = UDim2.new(0,380,0,116); flyModeLabel.Size = UDim2.new(0,260,0,20); flyModeLabel.BackgroundTransparency = 1; flyModeLabel.Font = Enum.Font.GothamBold; flyModeLabel.Text = "Fly Mode (BV to nearest):"
local fNormalBtn = Instance.new("TextButton", pageUni); fNormalBtn.Position = UDim2.new(0,380,0,140); fNormalBtn.Size = UDim2.new(0,84,0,32); fNormalBtn.Text = "Normal"
local fBehindBtn = Instance.new("TextButton", pageUni); fBehindBtn.Position = UDim2.new(0,472,0,140); fBehindBtn.Size = UDim2.new(0,84,0,32); fBehindBtn.Text = "Behind"
local fFrontBtn = Instance.new("TextButton", pageUni); fFrontBtn.Position = UDim2.new(0,564,0,140); fFrontBtn.Size = UDim2.new(0,84,0,32); fFrontBtn.Text = "Front"

local mixWalkLabel = Instance.new("TextLabel", pageUni); mixWalkLabel.Position = UDim2.new(0,380,0,196); mixWalkLabel.Size = UDim2.new(0,260,0,20); mixWalkLabel.BackgroundTransparency = 1; mixWalkLabel.Font = Enum.Font.GothamBold; mixWalkLabel.Text = "Mix Mode Walk+Look (applies when both active):"
local mWalkNormal = Instance.new("TextButton", pageUni); mWalkNormal.Position = UDim2.new(0,380,0,220); mWalkNormal.Size = UDim2.new(0,84,0,28); mWalkNormal.Text = "Normal"
local mWalkBehind = Instance.new("TextButton", pageUni); mWalkBehind.Position = UDim2.new(0,472,0,220); mWalkBehind.Size = UDim2.new(0,84,0,28); mWalkBehind.Text = "Behind"
local mWalkFront = Instance.new("TextButton", pageUni); mWalkFront.Position = UDim2.new(0,564,0,220); mWalkFront.Size = UDim2.new(0,84,0,28); mWalkFront.Text = "Front"

local mixFlyLabel = Instance.new("TextLabel", pageUni); mixFlyLabel.Position = UDim2.new(0,380,0,256); mixFlyLabel.Size = UDim2.new(0,260,0,20); mixFlyLabel.BackgroundTransparency = 1; mixFlyLabel.Font = Enum.Font.GothamBold; mixFlyLabel.Text = "Mix Mode Fly+Look (applies when both active):"
local mFlyNormal = Instance.new("TextButton", pageUni); mFlyNormal.Position = UDim2.new(0,380,0,280); mFlyNormal.Size = UDim2.new(0,84,0,28); mFlyNormal.Text = "Normal"
local mFlyBehind = Instance.new("TextButton", pageUni); mFlyBehind.Position = UDim2.new(0,472,0,280); mFlyBehind.Size = UDim2.new(0,84,0,28); mFlyBehind.Text = "Behind"
local mFlyFront = Instance.new("TextButton", pageUni); mFlyFront.Position = UDim2.new(0,564,0,280); mFlyFront.Size = UDim2.new(0,84,0,28); mFlyFront.Text = "Front"

local offsetLbl = Instance.new("TextLabel", pageUni); offsetLbl.Position = UDim2.new(0,380,0,320); offsetLbl.Size = UDim2.new(0,200,0,20); offsetLbl.BackgroundTransparency = 1; offsetLbl.Font = Enum.Font.Gotham; offsetLbl.Text = "Offset (studs for Behind/Front):"
local offsetBox = Instance.new("TextBox", pageUni); offsetBox.Position = UDim2.new(0,580,0,316); offsetBox.Size = UDim2.new(0,108,0,28); offsetBox.Text = tostring(uniOffset); offsetBox.ClearTextOnFocus = false; offsetBox.Font = Enum.Font.Gotham

local uniLookBtn = Instance.new("TextButton", pageUni); uniLookBtn.Position = UDim2.new(0,8,0,324); uniLookBtn.Size = UDim2.new(0,360,0,40); uniLookBtn.Text = "Universal LookAt (nearest) : OFF"; uniLookBtn.Font = Enum.Font.Gotham; uniLookBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
local uniLookV2Btn = Instance.new("TextButton", pageUni); uniLookV2Btn.Position = UDim2.new(0,8,0,384); uniLookV2Btn.Size = UDim2.new(0,360,0,40); uniLookV2Btn.Text = "Universal LookAtV2 (nearest): OFF"; uniLookV2Btn.Font = Enum.Font.Gotham; uniLookV2Btn.BackgroundColor3 = Color3.fromRGB(90,90,90)

-- universal look keyboxes (main/universal already included earlier)
local uniLookKeyBox = Instance.new("TextBox", pageUni); uniLookKeyBox.Position = UDim2.new(0,380,0,324); uniLookKeyBox.Size = UDim2.new(0,68,0,40); uniLookKeyBox.Text = ""; uniLookKeyBox.PlaceholderText = "Key"; uniLookKeyBox.ClearTextOnFocus = false; uniLookKeyBox.Font = Enum.Font.Gotham; uniLookKeyBox.BackgroundTransparency = 0.6
local uniLookV2KeyBox = Instance.new("TextBox", pageUni); uniLookV2KeyBox.Position = UDim2.new(0,380,0,384); uniLookV2KeyBox.Size = UDim2.new(0,68,0,40); uniLookV2KeyBox.Text = ""; uniLookV2KeyBox.PlaceholderText = "Key"; uniLookV2KeyBox.ClearTextOnFocus = false; uniLookV2KeyBox.Font = Enum.Font.Gotham; uniLookV2KeyBox.BackgroundTransparency = 0.6

-- Team page
local teamTitle = Instance.new("TextLabel", pageTeam); teamTitle.Position = UDim2.new(0,8,0,8); teamTitle.Size = UDim2.new(1,-16,0,22); teamTitle.BackgroundTransparency = 1; teamTitle.Font = Enum.Font.GothamBold; teamTitle.Text = "Team Controls & NPC Beta"

local teamCheckBtn = Instance.new("TextButton", pageTeam); teamCheckBtn.Position = UDim2.new(0,8,0,48); teamCheckBtn.Size = UDim2.new(0,320,0,36); teamCheckBtn.Text = "Team Check (don't target own team): OFF"; teamCheckBtn.Font = Enum.Font.Gotham; teamCheckBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
local teamFinderLbl = Instance.new("TextLabel", pageTeam); teamFinderLbl.Position = UDim2.new(0,8,0,96); teamFinderLbl.Size = UDim2.new(0,160,0,20); teamFinderLbl.BackgroundTransparency = 1; teamFinderLbl.Font = Enum.Font.Gotham; teamFinderLbl.Text = "Selected Team:"
local teamFinderBtn = Instance.new("TextButton", pageTeam); teamFinderBtn.Position = UDim2.new(0,176,0,92); teamFinderBtn.Size = UDim2.new(0,220,0,28); teamFinderBtn.Text = "<none>"; teamFinderBtn.Font = Enum.Font.Gotham
local teamTargetBtn = Instance.new("TextButton", pageTeam); teamTargetBtn.Position = UDim2.new(0,8,0,136); teamTargetBtn.Size = UDim2.new(0,320,0,36); teamTargetBtn.Text = "Team Target (only target selected team): OFF"; teamTargetBtn.Font = Enum.Font.Gotham; teamTargetBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)

local npcBetaBtn = Instance.new("TextButton", pageTeam); npcBetaBtn.Position = UDim2.new(0,8,0,188); npcBetaBtn.Size = UDim2.new(0,320,0,36); npcBetaBtn.Text = "LookAt NPCs (beta) for universal look: OFF"; npcBetaBtn.Font = Enum.Font.Gotham; npcBetaBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)

-- Remove all keybinds & Keybinds Panel toggle
local removeAllBtn = Instance.new("TextButton", pageTeam)
removeAllBtn.Position = UDim2.new(0,8,0,240)
removeAllBtn.Size = UDim2.new(0,220,0,36)
removeAllBtn.Text = "Remove All Keybinds"
removeAllBtn.Font = Enum.Font.Gotham
removeAllBtn.BackgroundColor3 = Color3.fromRGB(140,60,60)

local keybindsPanelBtn = Instance.new("TextButton", pageTeam)
keybindsPanelBtn.Position = UDim2.new(0,240,0,240)
keybindsPanelBtn.Size = UDim2.new(0,220,0,36)
keybindsPanelBtn.Text = "Toggle Keybinds Panel"
keybindsPanelBtn.Font = Enum.Font.Gotham
keybindsPanelBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)

-- Player list building
local playerRows = {}
local function makeRow(plr)
    local f = Instance.new("Frame")
    f.Size = UDim2.new(1, -12, 0, 36)
    f.BackgroundColor3 = Color3.fromRGB(30,30,32)
    f.BorderSizePixel = 0
    local name = Instance.new("TextLabel", f)
    name.Size = UDim2.new(0.6, 0, 1, 0)
    name.Position = UDim2.new(0,8,0,0)
    name.BackgroundTransparency = 1
    name.Font = Enum.Font.Gotham
    name.TextSize = 14
    name.Text = plr.Name
    name.TextColor3 = Color3.fromRGB(230,230,230)
    name.TextXAlignment = Enum.TextXAlignment.Left
    local btn = Instance.new("TextButton", f)
    btn.Size = UDim2.new(0,80,0,28)
    btn.Position = UDim2.new(1, -92, 0.5, -14)
    btn.Text = "Select"
    btn.Font = Enum.Font.Gotham
    btn.BackgroundColor3 = Color3.fromRGB(70,120,200)
    btn.TextColor3 = Color3.new(1,1,1)
    return {frame = f, name = name, btn = btn}
end

local function refreshPlayers()
    for _,c in ipairs(playerScroll:GetChildren()) do if c:IsA("Frame") then c:Destroy() end end
    playerRows = {}
    for _,p in ipairs(Players:GetPlayers()) do
        if p ~= LocalPlayer then
            local r = makeRow(p)
            r.frame.Parent = playerScroll
            r.btn.MouseButton1Click:Connect(function()
                selectedPlayer = p
                selLabel.Text = "Selected: "..p.Name
                for _,v in pairs(playerRows) do v.frame.BackgroundColor3 = Color3.fromRGB(30,30,32) end
                r.frame.BackgroundColor3 = Color3.fromRGB(45,45,48)
            end)
            playerRows[p] = r
        end
    end
    local count = 0
    for _,c in ipairs(playerScroll:GetChildren()) do if c:IsA("Frame") then count = count + 1 end end
    playerScroll.CanvasSize = UDim2.new(0,0,0, count * 42 + 12)
end
refreshPlayers()
Players.PlayerAdded:Connect(refreshPlayers)
Players.PlayerRemoving:Connect(refreshPlayers)

-- Utility: normalize key string
local function normalizeKeyString(s)
    local t = tostring(s or ""):gsub("%s+", ""):upper()
    return t
end

-- Input handling for keybinds (includes new keys)
UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed then return end
    if typingInTextBox then return end
    if input.UserInputType == Enum.UserInputType.Keyboard then
        local keyName = input.KeyCode.Name:upper()
        -- Look / LookV2
        if lookKey ~= "" and keyName == lookKey then
            lookActive = not lookActive
            lookBtn.Text = lookActive and "LookAt (XY): ON" or "LookAt (XY): OFF"
            if lookActive then
                universalLook = false; uniLookBtn.Text = "Universal LookAt (nearest) : OFF"
                lookV2Active = false; lookV2Btn.Text = "LookAtV2 (XYZ+Roll): OFF"
            end
        elseif lookV2Key ~= "" and keyName == lookV2Key then
            lookV2Active = not lookV2Active
            lookV2Btn.Text = lookV2Active and "LookAtV2 (XYZ+Roll): ON" or "LookAtV2 (XYZ+Roll): OFF"
            if lookV2Active then
                universalLookV2 = false; uniLookV2Btn.Text = "Universal LookAtV2 (nearest): OFF"
                lookActive = false; lookBtn.Text = "LookAt (XY): OFF"
            end
        elseif uniLookKey ~= "" and keyName == uniLookKey then
            universalLook = not universalLook
            uniLookBtn.Text = universalLook and "Universal LookAt (nearest) : ON" or "Universal LookAt (nearest) : OFF"
            if universalLook then lookActive = false; lookBtn.Text = "LookAt (XY): OFF"; universalLookV2 = false; uniLookV2Btn.Text = "Universal LookAtV2 (nearest): OFF" end
        elseif uniLookV2Key ~= "" and keyName == uniLookV2Key then
            universalLookV2 = not universalLookV2
            uniLookV2Btn.Text = universalLookV2 and "Universal LookAtV2 (nearest): ON" or "Universal LookAtV2 (nearest): OFF"
            if universalLookV2 then lookV2Active = false; lookV2Btn.Text = "LookAtV2 (XYZ+Roll): OFF"; universalLook = false; uniLookBtn.Text = "Universal LookAt (nearest) : OFF" end

        -- CWalk and UniForward
        elseif cwalkKey ~= "" and keyName == cwalkKey then
            cframeWalkActive = not cframeWalkActive
            cwalkBtn.Text = cframeWalkActive and "CFrame Walk (to selected): ON" or "CFrame Walk (to selected): OFF"
            cwalkBtn.BackgroundColor3 = cframeWalkActive and Color3.fromRGB(160,60,60) or Color3.fromRGB(90,90,90)
            if cframeWalkActive then
                universalForwardActive = false; uniForwardBtn.Text = "Universal Forward CFrame-Walk (HRP facing): OFF"; uniForwardBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
                universalWalkToPlayersActive = false; uniToPlayersBtn.Text = "Universal Walk-To-Nearest Player: OFF"; uniToPlayersBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
                universalAutoFly = false; uniAutoFlyBtn.Text = "Universal AutoFly (BV to nearest): OFF"; uniAutoFlyBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
                flyActive = false; flyBtn.Text = "Fly (BV to selected): OFF"; flyBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
                removeControllers()
            end
        elseif uniForwardKey ~= "" and keyName == uniForwardKey then
            universalForwardActive = not universalForwardActive
            uniForwardBtn.Text = universalForwardActive and "Universal Forward CFrame-Walk (HRP facing): ON" or "Universal Forward CFrame-Walk (HRP facing): OFF"
            uniForwardBtn.BackgroundColor3 = universalForwardActive and Color3.fromRGB(160,60,60) or Color3.fromRGB(90,90,90)
            if universalForwardActive then
                cframeWalkActive = false; cwalkBtn.Text = "CFrame Walk (to selected): OFF"; cwalkBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
                if not universalAutoFly and not flyActive then removeControllers() end
            end
        -- UniToPlayers
        elseif uniToPlayersKey ~= "" and keyName == uniToPlayersKey then
            universalWalkToPlayersActive = not universalWalkToPlayersActive
            uniToPlayersBtn.Text = universalWalkToPlayersActive and "Universal Walk-To-Nearest Player: ON" or "Universal Walk-To-Nearest Player: OFF"
            uniToPlayersBtn.BackgroundColor3 = universalWalkToPlayersActive and Color3.fromRGB(160,60,60) or Color3.fromRGB(90,90,90)
            if universalWalkToPlayersActive then
                cframeWalkActive = false; cwalkBtn.Text = "CFrame Walk (to selected): OFF"; cwalkBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
                universalForwardActive = false; uniForwardBtn.Text = "Universal Forward CFrame-Walk (HRP facing): OFF"; uniForwardBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
                if not universalAutoFly and not flyActive then removeControllers() end
            end
        -- UniAutoFly
        elseif uniAutoFlyKey ~= "" and keyName == uniAutoFlyKey then
            universalAutoFly = not universalAutoFly
            uniAutoFlyBtn.Text = universalAutoFly and "Universal AutoFly (BV to nearest): ON" or "Universal AutoFly (BV to nearest): OFF"
            uniAutoFlyBtn.BackgroundColor3 = universalAutoFly and Color3.fromRGB(160,60,60) or Color3.fromRGB(90,90,90)
            if universalAutoFly then
                ensureControllers()
                universalForwardActive = false; uniForwardBtn.Text = "Universal Forward CFrame-Walk (HRP facing): OFF"; uniForwardBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
                universalWalkToPlayersActive = false; uniToPlayersBtn.Text = "Universal Walk-To-Nearest Player: OFF"; uniToPlayersBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
            else
                if not flyActive and not aboveActive and not universalAboveActive then removeControllers() end
            end
        -- Fly (selected)
        elseif flyKey ~= "" and keyName == flyKey then
            flyActive = not flyActive
            flyBtn.Text = flyActive and "Fly (BV to selected): ON" or "Fly (BV to selected): OFF"
            flyBtn.BackgroundColor3 = flyActive and Color3.fromRGB(160,60,60) or Color3.fromRGB(90,90,90)
            if flyActive then
                ensureControllers()
                cframeWalkActive = false; cwalkBtn.Text = "CFrame Walk (to selected): OFF"; cwalkBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
                universalForwardActive = false; uniForwardBtn.Text = "Universal Forward CFrame-Walk (HRP facing): OFF"; uniForwardBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
                universalWalkToPlayersActive = false; uniToPlayersBtn.Text = "Universal Walk-To-Nearest Player: OFF"; uniToPlayersBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
            else
                if not universalAutoFly and not aboveActive and not universalAboveActive then removeControllers() end
            end
        -- Above (selected)
        elseif aboveKey ~= "" and keyName == aboveKey then
            aboveActive = not aboveActive
            aboveBtn.Text = aboveActive and "Above: ON" or "Above: OFF"
            aboveBtn.BackgroundColor3 = aboveActive and Color3.fromRGB(160,60,60) or Color3.fromRGB(90,90,90)
            if aboveActive then
                cframeWalkActive = false; cwalkBtn.Text = "CFrame Walk (to selected): OFF"; cwalkBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
                universalForwardActive = false; uniForwardBtn.Text = "Universal Forward CFrame-Walk (HRP facing): OFF"; uniForwardBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
                universalWalkToPlayersActive = false; uniToPlayersBtn.Text = "Universal Walk-To-Nearest Player: OFF"; uniToPlayersBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
                flyActive = false; flyBtn.Text = "Fly (BV to selected): OFF"; flyBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
                universalAutoFly = false; uniAutoFlyBtn.Text = "Universal AutoFly (BV to nearest): OFF"; uniAutoFlyBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
            end
        -- Universal Above
        elseif uniAboveKey ~= "" and keyName == uniAboveKey then
            universalAboveActive = not universalAboveActive
            uniAboveBtn.Text = universalAboveActive and "Universal Above (nearest): ON" or "Universal Above (nearest): OFF"
            uniAboveBtn.BackgroundColor3 = universalAboveActive and Color3.fromRGB(160,60,60) or Color3.fromRGB(90,90,90)
            if universalAboveActive then
                -- disable conflicting modes
                cframeWalkActive = false; cwalkBtn.Text = "CFrame Walk (to selected): OFF"; cwalkBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
                universalForwardActive = false; uniForwardBtn.Text = "Universal Forward CFrame-Walk (HRP facing): OFF"; uniForwardBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
                universalWalkToPlayersActive = false; uniToPlayersBtn.Text = "Universal Walk-To-Nearest Player: OFF"; uniToPlayersBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
                flyActive = false; flyBtn.Text = "Fly (BV to selected): OFF"; flyBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
                universalAutoFly = false; uniAutoFlyBtn.Text = "Universal AutoFly (BV to nearest): OFF"; uniAutoFlyBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
                aboveActive = false; aboveBtn.Text = "Above: OFF"; aboveBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
            end
        end
    end
end)

-- Focus wiring for textboxes to prevent accidental keybind toggle while typing
local function wireFocus(tb)
    if not tb or not tb:IsA("TextBox") then return end
    tb.Focused:Connect(function() typingInTextBox = true end)
    tb.FocusLost:Connect(function() typingInTextBox = false end)
end

-- Wire all textboxes (existing + new)
local allTextBoxes = {
    walkSpeedBox, walkPredBox, lookPredBox, lookV2PredBox,
    flySpeedBox, flyPredBox, aboveBox, aboveTweenBox, offsetBox,
    lookKeyBox, lookV2KeyBox, uniLookKeyBox, uniLookV2KeyBox,
    cwalkKeyBox, uniForwardKeyBox, uniToPlayersKeyBox, uniAutoFlyKeyBox,
    flyKeyBox, aboveKeyBox, uniAboveKeyBox
}
for _,tb in ipairs(allTextBoxes) do
    wireFocus(tb)
end

-- Keybox focus behaviors (store binding on FocusLost)
lookKeyBox.FocusLost:Connect(function()
    local k = normalizeKeyString(lookKeyBox.Text)
    lookKey = k
    lookKeyBox.Text = k
end)
lookV2KeyBox.FocusLost:Connect(function()
    local k = normalizeKeyString(lookV2KeyBox.Text)
    lookV2Key = k
    lookV2KeyBox.Text = k
end)
uniLookKeyBox.FocusLost:Connect(function()
    local k = normalizeKeyString(uniLookKeyBox.Text)
    uniLookKey = k
    uniLookKeyBox.Text = k
end)
uniLookV2KeyBox.FocusLost:Connect(function()
    local k = normalizeKeyString(uniLookV2KeyBox.Text)
    uniLookV2Key = k
    uniLookV2KeyBox.Text = k
end)
cwalkKeyBox.FocusLost:Connect(function()
    local k = normalizeKeyString(cwalkKeyBox.Text)
    cwalkKey = k
    cwalkKeyBox.Text = k
end)
uniForwardKeyBox.FocusLost:Connect(function()
    local k = normalizeKeyString(uniForwardKeyBox.Text)
    uniForwardKey = k
    uniForwardKeyBox.Text = k
end)
uniToPlayersKeyBox.FocusLost:Connect(function()
    local k = normalizeKeyString(uniToPlayersKeyBox.Text)
    uniToPlayersKey = k
    uniToPlayersKeyBox.Text = k
end)
uniAutoFlyKeyBox.FocusLost:Connect(function()
    local k = normalizeKeyString(uniAutoFlyKeyBox.Text)
    uniAutoFlyKey = k
    uniAutoFlyKeyBox.Text = k
end)
flyKeyBox.FocusLost:Connect(function()
    local k = normalizeKeyString(flyKeyBox.Text)
    flyKey = k
    flyKeyBox.Text = k
end)
aboveKeyBox.FocusLost:Connect(function()
    local k = normalizeKeyString(aboveKeyBox.Text)
    aboveKey = k
    aboveKeyBox.Text = k
end)
uniAboveKeyBox.FocusLost:Connect(function()
    local k = normalizeKeyString(uniAboveKeyBox.Text)
    uniAboveKey = k
    uniAboveKeyBox.Text = k
end)

-- Team finder logic
local teamsList = TeamsService:GetTeams()
local teamIndex = 0
local function updateTeamFinderLabel()
    if teamSelected then teamFinderBtn.Text = tostring(teamSelected.Name or "<none>") else teamFinderBtn.Text = "<none>" end
end
teamFinderBtn.MouseButton1Click:Connect(function()
    if #teamsList == 0 then teamsList = TeamsService:GetTeams() end
    if #teamsList == 0 then teamSelected = nil; updateTeamFinderLabel(); return end
    teamIndex = ((teamIndex) % #teamsList) + 1
    teamSelected = teamsList[teamIndex]
    updateTeamFinderLabel()
end)

teamCheckBtn.MouseButton1Click:Connect(function()
    teamCheckEnabled = not teamCheckEnabled
    teamCheckBtn.Text = "Team Check (don't target own team): " .. (teamCheckEnabled and "ON" or "OFF")
    teamCheckBtn.BackgroundColor3 = teamCheckEnabled and Color3.fromRGB(160,60,60) or Color3.fromRGB(90,90,90)
end)
teamTargetBtn.MouseButton1Click:Connect(function()
    teamOnlyTarget = not teamOnlyTarget
    teamTargetBtn.Text = "Team Target (only target selected team): " .. (teamOnlyTarget and "ON" or "OFF")
    teamTargetBtn.BackgroundColor3 = teamOnlyTarget and Color3.fromRGB(160,60,60) or Color3.fromRGB(90,90,90)
end)

npcBetaBtn.MouseButton1Click:Connect(function()
    lookAtNPCsBeta = not lookAtNPCsBeta
    npcBetaBtn.Text = "LookAt NPCs (beta) for universal look: " .. (lookAtNPCsBeta and "ON" or "OFF")
    npcBetaBtn.BackgroundColor3 = lookAtNPCsBeta and Color3.fromRGB(160,60,60) or Color3.fromRGB(90,90,90)
end)

-- Sanitization handlers
walkSpeedBox.FocusLost:Connect(function() local v = tonumber(walkSpeedBox.Text) or DEFAULT_CFRAME_WALK_SPEED; walkSpeedBox.Text = tostring(math.max(0, v)) end)
walkPredBox.FocusLost:Connect(function() local v = tonumber(walkPredBox.Text) or DEFAULT_PRED; walkPredBox.Text = tostring(math.max(0, v)) end)
lookPredBox.FocusLost:Connect(function() local v = tonumber(lookPredBox.Text) or DEFAULT_LOOK_PRED; lookPredBox.Text = tostring(math.max(0, v)) end)
lookV2PredBox.FocusLost:Connect(function() local v = tonumber(lookV2PredBox.Text) or DEFAULT_LOOKV2_PRED; lookV2PredBox.Text = tostring(math.max(0, v)) end)
flySpeedBox.FocusLost:Connect(function() local v = tonumber(flySpeedBox.Text) or DEFAULT_BV_SPEED; flySpeedBox.Text = tostring(math.max(0, v)) end)
flyPredBox.FocusLost:Connect(function() local v = tonumber(flyPredBox.Text) or DEFAULT_PRED; flyPredBox.Text = tostring(math.max(0, v)) end)
aboveBox.FocusLost:Connect(function() aboveBox.Text = tostring(math.max(0, tonumber(aboveBox.Text) or 8)) end)
aboveTweenBox.FocusLost:Connect(function() aboveTweenBox.Text = tostring(math.max(1e-4, tonumber(aboveTweenBox.Text) or DEFAULT_ABOVE_TWEEN)) end)
offsetBox.FocusLost:Connect(function() uniOffset = math.max(0, tonumber(offsetBox.Text) or uniOffset); offsetBox.Text = tostring(uniOffset) end)

-- Buttons: toggles and their basic behaviors
cwalkBtn.MouseButton1Click:Connect(function()
    cframeWalkActive = not cframeWalkActive
    cwalkBtn.Text = cframeWalkActive and "CFrame Walk (to selected): ON" or "CFrame Walk (to selected): OFF"
    cwalkBtn.BackgroundColor3 = cframeWalkActive and Color3.fromRGB(160,60,60) or Color3.fromRGB(90,90,90)
    if cframeWalkActive then
        universalForwardActive = false; uniForwardBtn.Text = "Universal Forward CFrame-Walk (HRP facing): OFF"; uniForwardBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
        if not universalAutoFly and not flyActive then removeControllers() end
    end
end)

uniForwardBtn.MouseButton1Click:Connect(function()
    universalForwardActive = not universalForwardActive
    uniForwardBtn.Text = universalForwardActive and "Universal Forward CFrame-Walk (HRP facing): ON" or "Universal Forward CFrame-Walk (HRP facing): OFF"
    uniForwardBtn.BackgroundColor3 = universalForwardActive and Color3.fromRGB(160,60,60) or Color3.fromRGB(90,90,90)
    if universalForwardActive then
        cframeWalkActive = false; cwalkBtn.Text = "CFrame Walk (to selected): OFF"; cwalkBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
        if not universalAutoFly and not flyActive then removeControllers() end
    end
end)

uniToPlayersBtn.MouseButton1Click:Connect(function()
    universalWalkToPlayersActive = not universalWalkToPlayersActive
    uniToPlayersBtn.Text = universalWalkToPlayersActive and "Universal Walk-To-Nearest Player: ON" or "Universal Walk-To-Nearest Player: OFF"
    uniToPlayersBtn.BackgroundColor3 = universalWalkToPlayersActive and Color3.fromRGB(160,60,60) or Color3.fromRGB(90,90,90)
    if universalWalkToPlayersActive then
        cframeWalkActive = false; cwalkBtn.Text = "CFrame Walk (to selected): OFF"; cwalkBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
        universalForwardActive = false; uniForwardBtn.Text = "Universal Forward CFrame-Walk (HRP facing): OFF"; uniForwardBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
        if not universalAutoFly and not flyActive then removeControllers() end
    end
end)

uniAutoFlyBtn.MouseButton1Click:Connect(function()
    universalAutoFly = not universalAutoFly
    uniAutoFlyBtn.Text = universalAutoFly and "Universal AutoFly (BV to nearest): ON" or "Universal AutoFly (BV to nearest): OFF"
    uniAutoFlyBtn.BackgroundColor3 = universalAutoFly and Color3.fromRGB(160,60,60) or Color3.fromRGB(90,90,90)
    if universalAutoFly then
        ensureControllers()
        universalForwardActive = false; uniForwardBtn.Text = "Universal Forward CFrame-Walk (HRP facing): OFF"; uniForwardBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
        universalWalkToPlayersActive = false; uniToPlayersBtn.Text = "Universal Walk-To-Nearest Player: OFF"; uniToPlayersBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
    else
        if not flyActive and not aboveActive and not universalAboveActive then removeControllers() end
    end
end)

flyBtn.MouseButton1Click:Connect(function()
    flyActive = not flyActive
    flyBtn.Text = flyActive and "Fly (BV to selected): ON" or "Fly (BV to selected): OFF"
    flyBtn.BackgroundColor3 = flyActive and Color3.fromRGB(160,60,60) or Color3.fromRGB(90,90,90)
    if flyActive then
        ensureControllers()
        cframeWalkActive = false; cwalkBtn.Text = "CFrame Walk (to selected): OFF"; cwalkBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
        universalForwardActive = false; uniForwardBtn.Text = "Universal Forward CFrame-Walk (HRP facing): OFF"; uniForwardBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
        universalWalkToPlayersActive = false; uniToPlayersBtn.Text = "Universal Walk-To-Nearest Player: OFF"; uniToPlayersBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
    else
        if not universalAutoFly and not aboveActive and not universalAboveActive then removeControllers() end
    end
end)

-- Above (selected) logic (tween) with team target respect
local aboveThread = nil
aboveBtn.MouseButton1Click:Connect(function()
    aboveActive = not aboveActive
    aboveBtn.Text = aboveActive and "Above: ON" or "Above: OFF"
    aboveBtn.BackgroundColor3 = aboveActive and Color3.fromRGB(160,60,60) or Color3.fromRGB(90,90,90)
    if aboveActive then
        -- disable conflicting modes
        cframeWalkActive = false; cwalkBtn.Text = "CFrame Walk (to selected): OFF"; cwalkBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
        universalForwardActive = false; uniForwardBtn.Text = "Universal Forward CFrame-Walk (HRP facing): OFF"; uniForwardBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
        universalWalkToPlayersActive = false; uniToPlayersBtn.Text = "Universal Walk-To-Nearest Player: OFF"; uniToPlayersBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
        flyActive = false; flyBtn.Text = "Fly (BV to selected): OFF"; flyBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
        universalAutoFly = false; uniAutoFlyBtn.Text = "Universal AutoFly (BV to nearest): OFF"; uniAutoFlyBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)

        if aboveThread then aboveThread = nil end
        aboveThread = task.spawn(function()
            while aboveActive and screenGui.Parent do
                if selectedPlayer and isAlive(selectedPlayer) then
                    -- respect team targeting
                    if teamOnlyTarget and teamSelected and selectedPlayer.Team ~= teamSelected then
                        task.wait(0.12)
                        continue
                    end
                    if teamCheckEnabled and LocalPlayer.Team and selectedPlayer.Team and LocalPlayer.Team == selectedPlayer.Team then
                        task.wait(0.12)
                        continue
                    end

                    local tgt = bestPart(selectedPlayer)
                    if tgt then
                        local height = tonumber(aboveBox.Text) or 8
                        local tweenTime = tonumber(aboveTweenBox.Text) or DEFAULT_ABOVE_TWEEN
                        tweenTime = math.max(1e-4, tweenTime)
                        local abovePos = Vector3.new(tgt.Position.X, tgt.Position.Y + height, tgt.Position.Z)
                        local desiredCFrame = CFrame.new(abovePos, tgt.Position)
                        local char = LocalPlayer.Character
                        local hrp = char and (char:FindFirstChild("HumanoidRootPart") or char:FindFirstChild("UpperTorso") or char:FindFirstChild("Torso"))
                        if hrp then
                            local ok, tw = pcall(function()
                                return TweenService:Create(hrp, TweenInfo.new(tweenTime, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = desiredCFrame})
                            end)
                            if ok and tw then
                                tw:Play()
                                local waited = 0
                                while waited < tweenTime and tw.PlaybackState == Enum.PlaybackState.Playing and aboveActive do
                                    task.wait(math.min(0.03, tweenTime))
                                    waited = waited + 0.03
                                end
                                pcall(function() hrp.CFrame = desiredCFrame end)
                            else
                                pcall(function() hrp.CFrame = desiredCFrame end)
                                task.wait(0.05)
                            end
                        end
                    else
                        task.wait(0.12)
                    end
                else
                    task.wait(0.15)
                end
            end
        end)
    else
        aboveThread = nil
    end
end)

-- Universal Above (nearest) logic (tween) using getNearestAlivePlayerToMe (team-aware)
local uniAboveThread = nil
uniAboveBtn.MouseButton1Click:Connect(function()
    universalAboveActive = not universalAboveActive
    uniAboveBtn.Text = universalAboveActive and "Universal Above (nearest): ON" or "Universal Above (nearest): OFF"
    uniAboveBtn.BackgroundColor3 = universalAboveActive and Color3.fromRGB(160,60,60) or Color3.fromRGB(90,90,90)
    if universalAboveActive then
        -- disable conflicting toggles
        cframeWalkActive = false; cwalkBtn.Text = "CFrame Walk (to selected): OFF"; cwalkBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
        universalForwardActive = false; uniForwardBtn.Text = "Universal Forward CFrame-Walk (HRP facing): OFF"; uniForwardBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
        universalWalkToPlayersActive = false; uniToPlayersBtn.Text = "Universal Walk-To-Nearest Player: OFF"; uniToPlayersBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
        flyActive = false; flyBtn.Text = "Fly (BV to selected): OFF"; flyBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
        universalAutoFly = false; uniAutoFlyBtn.Text = "Universal AutoFly (BV to nearest): OFF"; uniAutoFlyBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)
        aboveActive = false; aboveBtn.Text = "Above: OFF"; aboveBtn.BackgroundColor3 = Color3.fromRGB(90,90,90)

        if uniAboveThread then uniAboveThread = nil end
        uniAboveThread = task.spawn(function()
            while universalAboveActive and screenGui.Parent do
                local targetCandidate = nil
                if lookAtNPCsBeta then
                    targetCandidate = getNearestNPCToMe()
                else
                    targetCandidate = getNearestAlivePlayerToMe() -- already respects team settings
                end
                if targetCandidate then
                    local tgtPart = nil
                    if typeof(targetCandidate) == "Instance" and targetCandidate:IsA("Model") and targetCandidate:FindFirstChildOfClass("Humanoid") then
                        tgtPart = targetCandidate:FindFirstChild("HumanoidRootPart") or targetCandidate:FindFirstChild("UpperTorso") or targetCandidate:FindFirstChild("Torso")
                    else
                        tgtPart = bestPart(targetCandidate)
                    end
                    if tgtPart then
                        local height = tonumber(aboveBox.Text) or 8
                        local tweenTime = tonumber(aboveTweenBox.Text) or DEFAULT_ABOVE_TWEEN
                        tweenTime = math.max(1e-4, tweenTime)
                        local abovePos = Vector3.new(tgtPart.Position.X, tgtPart.Position.Y + height, tgtPart.Position.Z)
                        local desiredCFrame = CFrame.new(abovePos, tgtPart.Position)
                        local char = LocalPlayer.Character
                        local hrp = char and (char:FindFirstChild("HumanoidRootPart") or char:FindFirstChild("UpperTorso") or char:FindFirstChild("Torso"))
                        if hrp then
                            local ok, tw = pcall(function()
                                return TweenService:Create(hrp, TweenInfo.new(tweenTime, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = desiredCFrame})
                            end)
                            if ok and tw then
                                tw:Play()
                                local waited = 0
                                while waited < tweenTime and tw.PlaybackState == Enum.PlaybackState.Playing and universalAboveActive do
                                    task.wait(math.min(0.03, tweenTime))
                                    waited = waited + 0.03
                                end
                                pcall(function() hrp.CFrame = desiredCFrame end)
                            else
                                pcall(function() hrp.CFrame = desiredCFrame end)
                                task.wait(0.05)
                            end
                        end
                    else
                        task.wait(0.12)
                    end
                else
                    task.wait(0.15)
                end
            end
        end)
    else
        uniAboveThread = nil
    end
end)

-- Look toggles (main)
lookBtn.MouseButton1Click:Connect(function()
    lookActive = not lookActive
    lookBtn.Text = lookActive and "LookAt (XY): ON" or "LookAt (XY): OFF"
    lookBtn.BackgroundColor3 = lookActive and Color3.fromRGB(160,60,60) or Color3.fromRGB(90,90,90)
    if lookActive then
        universalLook = false; uniLookBtn.Text = "Universal LookAt (nearest) : OFF"
        lookV2Active = false; lookV2Btn.Text = "LookAtV2 (XYZ+Roll): OFF"
    end
end)
lookV2Btn.MouseButton1Click:Connect(function()
    lookV2Active = not lookV2Active
    lookV2Btn.Text = lookV2Active and "LookAtV2 (XYZ+Roll): ON" or "LookAtV2 (XYZ+Roll): OFF"
    lookV2Btn.BackgroundColor3 = lookV2Active and Color3.fromRGB(160,60,60) or Color3.fromRGB(90,90,90)
    if lookV2Active then
        universalLookV2 = false; uniLookV2Btn.Text = "Universal LookAtV2 (nearest): OFF"
        lookActive = false; lookBtn.Text = "LookAt (XY): OFF"
    end
end)

-- Universal look toggles
uniLookBtn.MouseButton1Click:Connect(function()
    universalLook = not universalLook
    uniLookBtn.Text = universalLook and "Universal LookAt (nearest) : ON" or "Universal LookAt (nearest) : OFF"
    uniLookBtn.BackgroundColor3 = universalLook and Color3.fromRGB(160,60,60) or Color3.fromRGB(90,90,90)
    if universalLook then
        lookActive = false; lookBtn.Text = "LookAt (XY): OFF"
        universalLookV2 = false; uniLookV2Btn.Text = "Universal LookAtV2 (nearest): OFF"
    end
end)

uniLookV2Btn.MouseButton1Click:Connect(function()
    universalLookV2 = not universalLookV2
    uniLookV2Btn.Text = universalLookV2 and "Universal LookAtV2 (nearest): ON" or "Universal LookAtV2 (nearest): OFF"
    uniLookV2Btn.BackgroundColor3 = universalLookV2 and Color3.fromRGB(160,60,60) or Color3.fromRGB(90,90,90)
    if universalLookV2 then
        lookV2Active = false; lookV2Btn.Text = "LookAtV2 (XYZ+Roll): OFF"
        universalLook = false; uniLookBtn.Text = "Universal LookAt (nearest) : OFF"
    end
end)

-- Combat and mix UI handlers (same as v13)
local function updateCFrameModeUI() cNormalBtn.BackgroundColor3 = (uniCFrameMode == "Normal") and Color3.fromRGB(160,160,160) or Color3.fromRGB(70,70,70); cBehindBtn.BackgroundColor3 = (uniCFrameMode == "Behind") and Color3.fromRGB(160,160,160) or Color3.fromRGB(70,70,70); cFrontBtn.BackgroundColor3 = (uniCFrameMode == "Front") and Color3.fromRGB(160,160,160) or Color3.fromRGB(70,70,70) end
cNormalBtn.MouseButton1Click:Connect(function() uniCFrameMode = "Normal"; updateCFrameModeUI() end)
cBehindBtn.MouseButton1Click:Connect(function() uniCFrameMode = "Behind"; updateCFrameModeUI() end)
cFrontBtn.MouseButton1Click:Connect(function() uniCFrameMode = "Front"; updateCFrameModeUI() end)
updateCFrameModeUI()

local function updateFlyModeUI() fNormalBtn.BackgroundColor3 = (uniFlyMode == "Normal") and Color3.fromRGB(160,160,160) or Color3.fromRGB(70,70,70); fBehindBtn.BackgroundColor3 = (uniFlyMode == "Behind") and Color3.fromRGB(160,160,160) or Color3.fromRGB(70,70,70); fFrontBtn.BackgroundColor3 = (uniFlyMode == "Front") and Color3.fromRGB(160,160,160) or Color3.fromRGB(70,70,70) end
fNormalBtn.MouseButton1Click:Connect(function() uniFlyMode = "Normal"; updateFlyModeUI() end)
fBehindBtn.MouseButton1Click:Connect(function() uniFlyMode = "Behind"; updateFlyModeUI() end)
fFrontBtn.MouseButton1Click:Connect(function() uniFlyMode = "Front"; updateFlyModeUI() end)
updateFlyModeUI()

local function updateMixWalkUI() mWalkNormal.BackgroundColor3 = (uniMixWalkMode == "Normal") and Color3.fromRGB(160,160,160) or Color3.fromRGB(70,70,70); mWalkBehind.BackgroundColor3 = (uniMixWalkMode == "Behind") and Color3.fromRGB(160,160,160) or Color3.fromRGB(70,70,70); mWalkFront.BackgroundColor3 = (uniMixWalkMode == "Front") and Color3.fromRGB(160,160,160) or Color3.fromRGB(70,70,70) end
mWalkNormal.MouseButton1Click:Connect(function() uniMixWalkMode = "Normal"; updateMixWalkUI() end)
mWalkBehind.MouseButton1Click:Connect(function() uniMixWalkMode = "Behind"; updateMixWalkUI() end)
mWalkFront.MouseButton1Click:Connect(function() uniMixWalkMode = "Front"; updateMixWalkUI() end)
updateMixWalkUI()

local function updateMixFlyUI() mFlyNormal.BackgroundColor3 = (uniMixFlyMode == "Normal") and Color3.fromRGB(160,160,160) or Color3.fromRGB(70,70,70); mFlyBehind.BackgroundColor3 = (uniMixFlyMode == "Behind") and Color3.fromRGB(160,160,160) or Color3.fromRGB(70,70,70); mFlyFront.BackgroundColor3 = (uniMixFlyMode == "Front") and Color3.fromRGB(160,160,160) or Color3.fromRGB(70,70,70) end
mFlyNormal.MouseButton1Click:Connect(function() uniMixFlyMode = "Normal"; updateMixFlyUI() end)
mFlyBehind.MouseButton1Click:Connect(function() uniMixFlyMode = "Behind"; updateMixFlyUI() end)
mFlyFront.MouseButton1Click:Connect(function() uniMixFlyMode = "Front"; updateMixFlyUI() end)
updateMixFlyUI()

-- Tabs switching
t1.MouseButton1Click:Connect(function() pageMain.Visible = true; pageUni.Visible = false; pageTeam.Visible = false; t1.BackgroundColor3 = Color3.fromRGB(60,60,60); t2.BackgroundColor3 = Color3.fromRGB(36,36,40); t3.BackgroundColor3 = Color3.fromRGB(36,36,40) end)
t2.MouseButton1Click:Connect(function() pageMain.Visible = false; pageUni.Visible = true; pageTeam.Visible = false; t2.BackgroundColor3 = Color3.fromRGB(60,60,60); t1.BackgroundColor3 = Color3.fromRGB(36,36,40); t3.BackgroundColor3 = Color3.fromRGB(36,36,40) end)
t3.MouseButton1Click:Connect(function() pageMain.Visible = false; pageUni.Visible = false; pageTeam.Visible = true; t3.BackgroundColor3 = Color3.fromRGB(60,60,60); t1.BackgroundColor3 = Color3.fromRGB(36,36,40); t2.BackgroundColor3 = Color3.fromRGB(36,36,40) end)

-- Close and drag
closeBtn.MouseButton1Click:Connect(function()
    cframeWalkActive = false; universalForwardActive = false; universalWalkToPlayersActive = false; universalAutoFly = false; flyActive = false; aboveActive = false; universalAboveActive = false; universalLook = false; universalLookV2 = false
    removeControllers()
    screenGui:Destroy()
end)
do
    local dragging, dragStart, startPos = false, nil, nil
    header.InputBegan:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 then
            dragging = true; dragStart = input.Position; startPos = main.Position
            input.Changed:Connect(function() if input.UserInputState == Enum.UserInputState.End then dragging = false end end)
        end
    end)
    header.InputChanged:Connect(function(input)
        if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
            local delta = input.Position - dragStart
            main.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
        end
    end)
end

-- ===== Keybinds Panel (draggable, shows current binds and Clear All) =====
local keyPanel = Instance.new("Frame", screenGui)
keyPanel.Name = "KeybindsPanel"
keyPanel.Size = UDim2.new(0,300,0,260)
keyPanel.Position = UDim2.new(0.7, 0, 0.08, 0)
keyPanel.BackgroundColor3 = Color3.fromRGB(26,26,28)
keyPanel.Visible = false
keyPanel.BorderSizePixel = 0
local kpHeader = Instance.new("Frame", keyPanel)
kpHeader.Size = UDim2.new(1,0,0,28); kpHeader.Position = UDim2.new(0,0,0,0); kpHeader.BackgroundColor3 = Color3.fromRGB(34,34,36)
local kpTitle = Instance.new("TextLabel", kpHeader); kpTitle.Size = UDim2.new(1,-8,1,0); kpTitle.Position = UDim2.new(0,4,0,0); kpTitle.BackgroundTransparency = 1; kpTitle.Font = Enum.Font.GothamBold; kpTitle.TextSize = 14; kpTitle.Text = "Keybinds Panel"; kpTitle.TextColor3 = Color3.fromRGB(230,230,230); kpTitle.TextXAlignment = Enum.TextXAlignment.Left
local kpClose = Instance.new("TextButton", kpHeader); kpClose.Size = UDim2.new(0,24,0,20); kpClose.Position = UDim2.new(1,-28,0,4); kpClose.Text = "X"; kpClose.Font = Enum.Font.Gotham; kpClose.BackgroundColor3 = Color3.fromRGB(160,46,46)
kpClose.MouseButton1Click:Connect(function() keyPanel.Visible = false end)

-- labels inside panel
local function makeKPLabel(y, text)
    local lbl = Instance.new("TextLabel", keyPanel)
    lbl.Position = UDim2.new(0,8,0,y)
    lbl.Size = UDim2.new(1,-16,0,22)
    lbl.BackgroundTransparency = 1
    lbl.Font = Enum.Font.Gotham
    lbl.TextSize = 14
    lbl.TextColor3 = Color3.fromRGB(220,220,220)
    lbl.Text = text
    return lbl
end

local kpLook = makeKPLabel(0.12, "LookAt (main): ")
local kpLookV2 = makeKPLabel(0.20, "LookAtV2 (main): ")
local kpUniLook = makeKPLabel(0.28, "Universal Look: ")
local kpUniLookV2 = makeKPLabel(0.36, "Universal Look V2: ")
local kpCWalk = makeKPLabel(0.44, "CFrame Walk (main): ")
local kpUniForward = makeKPLabel(0.52, "Universal Forward: ")
local kpUniToPlayers = makeKPLabel(0.60, "Universal Walk-To-Nearest: ")
local kpUniAutoFly = makeKPLabel(0.68, "Universal AutoFly: ")
local kpFly = makeKPLabel(0.76, "Fly (selected): ")
local kpAbove = makeKPLabel(0.84, "Above (selected): ")
local kpUniAbove = makeKPLabel(0.92, "Universal Above: ")

local kpClear = Instance.new("TextButton", keyPanel)
kpClear.Position = UDim2.new(0.1,0,0.9,0)
kpClear.Size = UDim2.new(0.8,0,0,28)
kpClear.Text = "Clear All Keybinds"
kpClear.Font = Enum.Font.Gotham
kpClear.BackgroundColor3 = Color3.fromRGB(140,60,60)

-- panel dragging
do
    local dragging, dragStart, startPos = false, nil, nil
    kpHeader.InputBegan:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 then
            dragging = true; dragStart = input.Position; startPos = keyPanel.Position
            input.Changed:Connect(function() if input.UserInputState == Enum.UserInputState.End then dragging = false end end)
        end
    end)
    kpHeader.InputChanged:Connect(function(input)
        if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
            local delta = input.Position - dragStart
            keyPanel.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
        end
    end)
end

-- function to refresh panel labels
local function refreshKeyPanel()
    kpLook.Text = "LookAt (main): " .. (lookKey ~= "" and lookKey or "<none>")
    kpLookV2.Text = "LookAtV2 (main): " .. (lookV2Key ~= "" and lookV2Key or "<none>")
    kpUniLook.Text = "Universal Look: " .. (uniLookKey ~= "" and uniLookKey or "<none>")
    kpUniLookV2.Text = "Universal Look V2: " .. (uniLookV2Key ~= "" and uniLookV2Key or "<none>")
    kpCWalk.Text = "CFrame Walk (main): " .. (cwalkKey ~= "" and cwalkKey or "<none>")
    kpUniForward.Text = "Universal Forward: " .. (uniForwardKey ~= "" and uniForwardKey or "<none>")
    kpUniToPlayers.Text = "Universal Walk-To-Nearest: " .. (uniToPlayersKey ~= "" and uniToPlayersKey or "<none>")
    kpUniAutoFly.Text = "Universal AutoFly: " .. (uniAutoFlyKey ~= "" and uniAutoFlyKey or "<none>")
    kpFly.Text = "Fly (selected): " .. (flyKey ~= "" and flyKey or "<none>")
    kpAbove.Text = "Above (selected): " .. (aboveKey ~= "" and aboveKey or "<none>")
    kpUniAbove.Text = "Universal Above: " .. (uniAboveKey ~= "" and uniAboveKey or "<none>")
end

-- Clear all keybinds function
local function clearAllKeybinds()
    lookKey = ""; lookV2Key = ""; uniLookKey = ""; uniLookV2Key = ""; cwalkKey = ""; uniForwardKey = ""; uniToPlayersKey = ""; uniAutoFlyKey = ""; flyKey = ""; aboveKey = ""; uniAboveKey = ""
    -- clear UI boxes too
    lookKeyBox.Text = ""; lookV2KeyBox.Text = ""; uniLookKeyBox.Text = ""; uniLookV2KeyBox.Text = ""
    cwalkKeyBox.Text = ""; uniForwardKeyBox.Text = ""; uniToPlayersKeyBox.Text = ""; uniAutoFlyKeyBox.Text = ""
    flyKeyBox.Text = ""; aboveKeyBox.Text = ""; uniAboveKeyBox.Text = ""
    refreshKeyPanel()
end

kpClear.MouseButton1Click:Connect(clearAllKeybinds)
removeAllBtn.MouseButton1Click:Connect(clearAllKeybinds)

-- Toggle keybinds panel
keybindsPanelBtn.MouseButton1Click:Connect(function()
    keyPanel.Visible = not keyPanel.Visible
    if keyPanel.Visible then refreshKeyPanel() end
end)

-- RenderStepped loop: main behaviors
RunService.RenderStepped:Connect(function(dt)
    local now = tick()
    for _,p in ipairs(Players:GetPlayers()) do updatePlayerState(p, now) end

    -- CFrame Walk to selected (respecting modes & preds)
    if cframeWalkActive and selectedPlayer and isAlive(selectedPlayer) then
        if teamOnlyTarget and teamSelected and selectedPlayer.Team ~= teamSelected then
            -- skip
        else
            if teamCheckEnabled and LocalPlayer.Team and selectedPlayer.Team and LocalPlayer.Team == selectedPlayer.Team then
                -- skip
            else
                local hrp = LocalPlayer.Character and (LocalPlayer.Character:FindFirstChild("HumanoidRootPart") or LocalPlayer.Character:FindFirstChild("UpperTorso") or LocalPlayer.Character:FindFirstChild("Torso"))
                if hrp then
                    local stepDist = tonumber(walkSpeedBox.Text) or DEFAULT_CFRAME_WALK_SPEED
                    local desired = computeOffsetTarget(selectedPlayer, uniCFrameMode, uniOffset, false, tonumber(walkPredBox.Text) or DEFAULT_PRED)
                    if desired then cframeStepTowardsExact(hrp, desired, stepDist) end
                end
            end
        end
    end

    -- Universal forward (HRP facing)
    if universalForwardActive then
        local hrp = LocalPlayer.Character and (LocalPlayer.Character:FindFirstChild("HumanoidRootPart") or LocalPlayer.Character:FindFirstChild("UpperTorso") or LocalPlayer.Character:FindFirstChild("Torso"))
        if hrp then
            local stepDist = tonumber(walkSpeedBox.Text) or DEFAULT_CFRAME_WALK_SPEED
            cframeMoveForwardHorizontalExact_ByHRP(hrp, stepDist)
        end
    end

    -- Universal Walk-To-Nearest Player
    if universalWalkToPlayersActive then
        local nearest = getNearestAlivePlayerToMe()
        local hrp = LocalPlayer.Character and (LocalPlayer.Character:FindFirstChild("HumanoidRootPart") or LocalPlayer.Character:FindFirstChild("UpperTorso") or LocalPlayer.Character:FindFirstChild("Torso"))
        if hrp and nearest and isAlive(nearest) then
            local desired = computeOffsetTarget(nearest, uniCFrameMode, uniOffset, false, tonumber(walkPredBox.Text) or DEFAULT_PRED)
            if desired then cframeStepTowardsExact(hrp, desired, tonumber(walkSpeedBox.Text) or DEFAULT_CFRAME_WALK_SPEED) end
        end
    end

    -- Fly (BV) to selected (respects teamOnlyTarget/teamCheck)
    if flyActive and selectedPlayer and isAlive(selectedPlayer) then
        if teamOnlyTarget and teamSelected and selectedPlayer.Team ~= teamSelected then
            -- skip
        else
            if teamCheckEnabled and LocalPlayer.Team and selectedPlayer.Team and LocalPlayer.Team == selectedPlayer.Team then
                -- skip
            else
                local desired = computeOffsetTarget(selectedPlayer, uniFlyMode, uniOffset, true, tonumber(flyPredBox.Text) or DEFAULT_PRED)
                if desired then flyTowardPositionBV(desired, tonumber(flySpeedBox.Text) or DEFAULT_BV_SPEED) end
            end
        end
    end

    -- Universal AutoFly (respects team rules)
    if universalAutoFly then
        local nearest
        if teamOnlyTarget and teamSelected then
            local myRoot = LocalPlayer.Character and (LocalPlayer.Character:FindFirstChild("HumanoidRootPart") or LocalPlayer.Character:FindFirstChild("UpperTorso") or LocalPlayer.Character:FindFirstChild("Torso"))
            local best, bestD = nil, math.huge
            if myRoot then
                for _,p in ipairs(Players:GetPlayers()) do
                    if p ~= LocalPlayer and isAlive(p) and p.Team == teamSelected then
                        local pr = bestPart(p)
                        if pr then
                            local d = (pr.Position - myRoot.Position).Magnitude
                            if d < bestD then bestD = d; best = p end
                        end
                    end
                end
            end
            nearest = best
        else
            nearest = getNearestAlivePlayerToMe()
        end
        if nearest and isAlive(nearest) then
            local desired = computeOffsetTarget(nearest, uniFlyMode, uniOffset, true, tonumber(flyPredBox.Text) or DEFAULT_PRED)
            if desired then ensureControllers(); flyTowardPositionBV(desired, tonumber(flySpeedBox.Text) or DEFAULT_BV_SPEED) end
        end
    end

    -- Look behaviors (use separate Look preds)
    local lookPred = tonumber(lookPredBox.Text) or DEFAULT_LOOK_PRED
    local lookV2Pred = tonumber(lookV2PredBox.Text) or DEFAULT_LOOKV2_PRED

    -- Per-target look
    if lookActive and selectedPlayer and isAlive(selectedPlayer) then
        if teamOnlyTarget and teamSelected and selectedPlayer.Team ~= teamSelected then
            -- skip
        else
            if teamCheckEnabled and LocalPlayer.Team and selectedPlayer.Team and LocalPlayer.Team == selectedPlayer.Team then
                -- skip
            else
                if cframeWalkActive then
                    local desired = computeOffsetTarget(selectedPlayer, uniMixWalkMode, uniOffset, false, lookPred)
                    if desired then pcall(function() doLookAtPositionXY(desired) end) end
                else
                    local tgt = predictedPosition(selectedPlayer, lookPred)
                    if tgt then pcall(function() doLookAtPositionXY(tgt) end) end
                end
            end
        end
    end

    if lookV2Active and selectedPlayer and isAlive(selectedPlayer) then
        if teamOnlyTarget and teamSelected and selectedPlayer.Team ~= teamSelected then
            -- skip
        else
            if teamCheckEnabled and LocalPlayer.Team and selectedPlayer.Team and LocalPlayer.Team == selectedPlayer.Team then
                -- skip
            else
                if cframeWalkActive then
                    local desired = computeOffsetTarget(selectedPlayer, uniMixWalkMode, uniOffset, false, lookV2Pred)
                    if desired then pcall(function() doLookAtPositionV2(desired, 0) end) end
                else
                    local tgt = predictedPosition(selectedPlayer, lookV2Pred)
                    if tgt then pcall(function() doLookAtPositionV2(tgt, 0) end) end
                end
            end
        end
    end

    -- Universal Look: can target players respecting team rules or NPCs if beta enabled
    if universalLook then
        if lookAtNPCsBeta then
            local npc = getNearestNPCToMe()
            if npc then
                local tgtPart = npc:FindFirstChild("HumanoidRootPart") or npc:FindFirstChild("UpperTorso") or npc:FindFirstChild("Torso")
                if tgtPart then
                    if universalWalkToPlayersActive then
                        local desired = computeOffsetTarget(npc, uniMixWalkMode, uniOffset, false, lookPred)
                        if desired then pcall(function() doLookAtPositionXY(desired) end) end
                    else
                        local pred = predictedPosition(npc, lookPred)
                        if pred then pcall(function() doLookAtPositionXY(pred) end) end
                    end
                end
            end
        else
            local nearest = getNearestAlivePlayerToMe()
            if nearest and isAlive(nearest) then
                if universalWalkToPlayersActive then
                    local desired = computeOffsetTarget(nearest, uniMixWalkMode, uniOffset, false, lookPred)
                    if desired then pcall(function() doLookAtPositionXY(desired) end) end
                else
                    local tgt = predictedPosition(nearest, lookPred)
                    if tgt then pcall(function() doLookAtPositionXY(tgt) end) end
                end
            end
        end
    end

    if universalLookV2 then
        if lookAtNPCsBeta then
            local npc = getNearestNPCToMe()
            if npc then
                if universalAutoFly then
                    local desired = computeOffsetTarget(npc, uniMixFlyMode, uniOffset, true, lookV2Pred)
                    if desired then pcall(function() doLookAtPositionV2(desired, 0) end) end
                elseif universalWalkToPlayersActive then
                    local desired = computeOffsetTarget(npc, uniMixWalkMode, uniOffset, false, lookV2Pred)
                    if desired then pcall(function() doLookAtPositionV2(desired, 0) end) end
                else
                    local tgt = predictedPosition(npc, lookV2Pred)
                    if tgt then pcall(function() doLookAtPositionV2(tgt, 0) end) end
                end
            end
        else
            local nearest = getNearestAlivePlayerToMe()
            if nearest and isAlive(nearest) then
                if universalAutoFly then
                    local desired = computeOffsetTarget(nearest, uniMixFlyMode, uniOffset, true, lookV2Pred)
                    if desired then pcall(function() doLookAtPositionV2(desired, 0) end) end
                elseif universalWalkToPlayersActive then
                    local desired = computeOffsetTarget(nearest, uniMixWalkMode, uniOffset, false, lookV2Pred)
                    if desired then pcall(function() doLookAtPositionV2(desired, 0) end) end
                else
                    local tgt = predictedPosition(nearest, lookV2Pred)
                    if tgt then pcall(function() doLookAtPositionV2(tgt, 0) end) end
                end
            end
        end
    end

    -- Anti-stuck nudge
    local myHRP = LocalPlayer.Character and (LocalPlayer.Character:FindFirstChild("HumanoidRootPart") or LocalPlayer.Character:FindFirstChild("UpperTorso") or LocalPlayer.Character:FindFirstChild("Torso"))
    if myHRP then
        if not lastMyPos then lastMyPos = myHRP.Position; lastMovedAt = now end
        if (myHRP.Position - lastMyPos).Magnitude > STUCK_MOVE_EPS then
            lastMovedAt = now; lastMyPos = myHRP.Position
        else
            local activeCframeModes = cframeWalkActive or universalForwardActive or universalWalkToPlayersActive
            if activeCframeModes and (now - lastMovedAt) > STUCK_TIME_THRESHOLD then
                pcall(function() myHRP.CFrame = myHRP.CFrame + Vector3.new(0,1.6,0) end)
                lastMovedAt = now; lastMyPos = myHRP.Position
            end
        end
    end

    -- cleanup BV controllers when not used
    if not (flyActive or universalAutoFly) then
        if bv and bv.Velocity.Magnitude == 0 then removeControllers() end
    end

    -- refresh key panel labels if visible
    if keyPanel.Visible then refreshKeyPanel() end
end)

-- Wire up keybox focus flags for typing (ensure all are wired)
for _,tb in ipairs(allTextBoxes) do if tb and tb:IsA("TextBox") then wireFocus(tb) end end

-- Make sure panel labels show initial values
refreshKeyPanel()

warn("PlayerMover v13 loaded — Universal Above and keybinds active.")

Features & Information

this script was made by chatgpt open source and i hadn't really updated the sclript in a while when it was doing so good. Features: cframe forward, cframe walk, fly towards, above target, 3 pages Main,Universal,team and a playet targeter and keybinds i added after v12. note: above keybind kinda bugging out and won't work
#lookat#Playermover v#lookatv#target#lookat gui playermover gui

Community Comments (1)

reverb0012reverb0012Jan 31, 2026

also alfountain18 and reverb0012 are the same person

More Scripts for Universal Scripts