H2N V14 Script for Roblox

This is a Roblox script snippet that performs initial cleanup of specific game objects and sets up character references and network ownership for the local player's character.
 avatar
unknown
lua
3 months ago
71 kB
8
Indexable
-- H2N V14 - All Fixed
repeat task.wait() until game:IsLoaded()
if not game.PlaceId then repeat task.wait(1) until game.PlaceId end

pcall(function()
    for _, v in ipairs(workspace:GetDescendants()) do
        if v.Name and (v.Name:find("H2N_WP_") or v.Name:find("H2N_Duel_")) then v:Destroy() end
    end
end)

local Players    = game:GetService("Players")
local UIS        = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local HttpService= game:GetService("HttpService")
local StarterGui = game:GetService("StarterGui")
local TweenService=game:GetService("TweenService")
local LP         = Players.LocalPlayer
local Char, HRP, Hum

local function Setup(c)
    Char=c; HRP=c:WaitForChild("HumanoidRootPart",10); Hum=c:WaitForChild("Humanoid",10)
    if not HRP or not Hum then return end
    pcall(function() HRP:SetNetworkOwner(LP) end)
end
if LP.Character then Setup(LP.Character) end
LP.CharacterAdded:Connect(function(c) task.wait(0.1); Setup(c) end)

local State = {
    PlayerSpeed=false,StealSpeed=false,SpeedBoost=false,
    AutoPlayLeft=false,AutoPlayRight=false,AutoTrack=false,
    AutoGrab=false,AntiRagdoll=false,InfiniteJump=false,
    XrayBase=false,ESP=false,AntiSentry=false,
    MeleeAimbot=false,SpinBody=false,DuelTP=false,
    FloatEnabled=false,
}
local NormalSpeed=60; local StealSpeed=29; local TRACK_SPEED=35
local GRAB_RATE=0.06; local GRAB_RADIUS=10; local SideButtonSize=80
local menuW,menuH=370,320; local StealBarVisible=true
local EditMode=false; local ButtonPositions={}; local sideHiddenMap={}
local carryingBrainrot=false
local SPIN_SPEED=25; local XRAY_TRANSPARENCY=0.68
local DETECTION_DISTANCE=60; local PULL_DISTANCE=-5
local DUEL_APPROACH_SPD=60; local DUEL_RETURN_SPD=29

local FloatEnabled=false; local FloatHeight=10
local FloatConn=nil; local FloatOriginalY=nil

local L1=Vector3.new(-477,-5,92); local L2=Vector3.new(-484,-4,92)
local R1=Vector3.new(-477,-5,28); local R2=Vector3.new(-484,-4,27)
local TP_L=Vector3.new(-484,-4,97); local TP_R=Vector3.new(-483,-4,23)
local WP_PARTS={}
local WP_COLORS={
    L1=Color3.fromRGB(0,120,255),L2=Color3.fromRGB(0,220,255),
    R1=Color3.fromRGB(255,130,0),R2=Color3.fromRGB(255,50,50),
    TP_L=Color3.fromRGB(255,255,0),TP_R=Color3.fromRGB(255,255,0),
}

local function createWPPart(name,pos,color)
    local old=workspace:FindFirstChild("H2N_WP_"..name); if old then old:Destroy() end
    local part=Instance.new("Part")
    part.Name="H2N_WP_"..name; part.Size=Vector3.new(1.5,1.5,1.5)
    part.Position=pos; part.Anchored=true; part.CanCollide=false
    part.CanQuery=false; part.CastShadow=false
    part.Material=Enum.Material.Neon; part.Color=color; part.Transparency=0.1
    local bg=Instance.new("BillboardGui",part)
    bg.Size=UDim2.new(0,60,0,24); bg.StudsOffset=Vector3.new(0,1.8,0)
    bg.AlwaysOnTop=true; bg.LightInfluence=0; bg.Enabled=true
    local lbl=Instance.new("TextLabel",bg)
    lbl.Size=UDim2.new(1,0,1,0); lbl.BackgroundColor3=Color3.fromRGB(0,0,0)
    lbl.BackgroundTransparency=0.3; lbl.Text=name
    lbl.TextColor3=Color3.fromRGB(255,255,255); lbl.Font=Enum.Font.GothamBold; lbl.TextSize=16
    Instance.new("UICorner",lbl).CornerRadius=UDim.new(0,4)
    part.Parent=workspace; WP_PARTS[name]=part; return part
end
local function initWPParts()
    createWPPart("L1",L1,WP_COLORS.L1); createWPPart("L2",L2,WP_COLORS.L2)
    createWPPart("R1",R1,WP_COLORS.R1); createWPPart("R2",R2,WP_COLORS.R2)
    createWPPart("TP_L",TP_L,WP_COLORS.TP_L); createWPPart("TP_R",TP_R,WP_COLORS.TP_R)
end
local function getWP(name)
    local p=WP_PARTS[name]; if p and p.Parent then return p.Position end
    if name=="L1" then return L1 elseif name=="L2" then return L2
    elseif name=="R1" then return R1 elseif name=="R2" then return R2
    elseif name=="TP_L" then return TP_L elseif name=="TP_R" then return TP_R end
    return nil
end

local Keys={
    SpeedKey=Enum.KeyCode.V,InfJump=Enum.KeyCode.J,
    AutoPlayLeft=Enum.KeyCode.G,AutoPlayRight=Enum.KeyCode.H,
    AutoTrack=Enum.KeyCode.T,DuelTP=Enum.KeyCode.R,
}
local duel_myHome=nil; local duel_enemySide=nil; local duel_homeSet=false
local duel_lastTPTime=0; local duel_lastHitTime=0
local duel_timeInZone=0; local duel_currentZone=nil; local DuelTP_Target="RIGHT"
local DUEL_STAND_POINTS={LEFT=Vector3.new(-466,-6,114),RIGHT=Vector3.new(-466,-6,6)}
local DUEL_TP_POINTS={LEFT=TP_L,RIGHT=TP_R}
local DUEL_STAND_RADIUS=15; local DUEL_STAND_DURATION=2.5; local DUEL_TP_COOLDOWN=2
local homeDetectionEnabled=false

local CONFIG_FILE="H2N_Config.json"
local function SaveConfig()
    local cfg={
        NormalSpeed=NormalSpeed,StealSpeed=StealSpeed,TRACK_SPEED=TRACK_SPEED,
        GRAB_RATE=GRAB_RATE,GRAB_RADIUS=GRAB_RADIUS,SideButtonSize=SideButtonSize,
        ButtonPositions=ButtonPositions,menuW=menuW,menuH=menuH,
        DUEL_APPROACH_SPD=DUEL_APPROACH_SPD,DUEL_RETURN_SPD=DUEL_RETURN_SPD,
        DuelTP={Target=DuelTP_Target,Home=duel_myHome},
        FloatEnabled=FloatEnabled,FloatHeight=FloatHeight,
        L1={X=L1.X,Y=L1.Y,Z=L1.Z},L2={X=L2.X,Y=L2.Y,Z=L2.Z},
        R1={X=R1.X,Y=R1.Y,Z=R1.Z},R2={X=R2.X,Y=R2.Y,Z=R2.Z},
        Keys={SpeedKey=Keys.SpeedKey.Name,InfJump=Keys.InfJump.Name,
              AutoPlayLeft=Keys.AutoPlayLeft.Name,AutoPlayRight=Keys.AutoPlayRight.Name,
              AutoTrack=Keys.AutoTrack.Name,DuelTP=Keys.DuelTP.Name}
    }
    return pcall(function() writefile(CONFIG_FILE,HttpService:JSONEncode(cfg)) end)
end
local function LoadConfig()
    local ok,data=pcall(function() return HttpService:JSONDecode(readfile(CONFIG_FILE)) end)
    if not (ok and data) then return end
    NormalSpeed=data.NormalSpeed or NormalSpeed; StealSpeed=data.StealSpeed or StealSpeed
    TRACK_SPEED=data.TRACK_SPEED or TRACK_SPEED; GRAB_RATE=data.GRAB_RATE or GRAB_RATE
    GRAB_RADIUS=data.GRAB_RADIUS or GRAB_RADIUS; SideButtonSize=data.SideButtonSize or SideButtonSize
    ButtonPositions=data.ButtonPositions or {}; menuW=data.menuW or menuW; menuH=data.menuH or menuH
    DUEL_APPROACH_SPD=data.DUEL_APPROACH_SPD or DUEL_APPROACH_SPD
    DUEL_RETURN_SPD=data.DUEL_RETURN_SPD or DUEL_RETURN_SPD
    FloatEnabled=data.FloatEnabled or false; FloatHeight=data.FloatHeight or 10
    if data.DuelTP then
        if data.DuelTP.Target then DuelTP_Target=data.DuelTP.Target end
        if data.DuelTP.Home then
            duel_myHome=data.DuelTP.Home; duel_homeSet=true
            duel_enemySide=(duel_myHome=="LEFT") and "RIGHT" or "LEFT"
            DuelTP_Target=duel_enemySide
        end
    end
    if data.L1 then L1=Vector3.new(data.L1.X,data.L1.Y,data.L1.Z) end
    if data.L2 then L2=Vector3.new(data.L2.X,data.L2.Y,data.L2.Z) end
    if data.R1 then R1=Vector3.new(data.R1.X,data.R1.Y,data.R1.Z) end
    if data.R2 then R2=Vector3.new(data.R2.X,data.R2.Y,data.R2.Z) end
    if data.Keys then
        for k,v in pairs(data.Keys) do
            local e=Enum.KeyCode[v]; if e and Keys[k] then Keys[k]=e end
        end
    end
end
LoadConfig()

local function updateBrainrot(char)
    if not char then return end; local found=false
    for _,v in ipairs(char:GetDescendants()) do
        local n=(v.Name or ""):lower()
        if n:find("brainrot") or (n:find("brain") and n:find("rot")) then found=true; break end
    end
    carryingBrainrot=found
end
local function setupBrainrotEvents(char)
    if not char then return end; updateBrainrot(char)
    char.DescendantAdded:Connect(function() updateBrainrot(char) end)
    char.DescendantRemoving:Connect(function() updateBrainrot(char) end)
end
if Char then setupBrainrotEvents(Char) end
LP.CharacterAdded:Connect(function(c) task.wait(0.1); Char=c; setupBrainrotEvents(c) end)

local speedJumpCooldown=0; local lastVelX,lastVelZ=0,0
local function StartPlayerSpeed() State.PlayerSpeed=true end
local function StopPlayerSpeed()  State.PlayerSpeed=false end
local function StartStealSpeed()  State.StealSpeed=true end
local function StopStealSpeed()   State.StealSpeed=false end
local function StartSpeedBoost()  State.SpeedBoost=true; State.PlayerSpeed=true; State.StealSpeed=true end
local function StopSpeedBoost()   State.SpeedBoost=false; State.PlayerSpeed=false; State.StealSpeed=false end

local aplPhase=1; local aprPhase=1
local StopAutoPlayLeft; local StopAutoPlayRight; local Notify

local antiRagdollConn=nil; local antiRagdollLoopConn=nil; local antiKnockbackConn=nil
local antiRagdollEnabled=false

local function restoreControls()
    pcall(function()
        local PlayerModule=LP.PlayerScripts:FindFirstChild("PlayerModule")
        if PlayerModule then require(PlayerModule:FindFirstChild("ControlModule")):Enable() end
    end)
end
local function fixRagdoll(char,hum,root)
    if not char or not hum then return end
    pcall(function()
        if hum.PlatformStand then hum.PlatformStand=false end
        hum:ChangeState(Enum.HumanoidStateType.Running)
        workspace.CurrentCamera.CameraSubject=hum
    end)
    for _,obj in ipairs(char:GetDescendants()) do
        if obj:IsA("BallSocketConstraint") or obj:IsA("NoCollisionConstraint") or obj:IsA("HingeConstraint") then
            pcall(function() obj:Destroy() end)
        end
    end
    restoreControls()
    if root then
        pcall(function() root.AssemblyLinearVelocity=Vector3.new(0,0,0) end)
        pcall(function() root.AssemblyAngularVelocity=Vector3.new(0,0,0) end)
    end
end
local function startAntiKnockback()
    if antiKnockbackConn then return end
    antiKnockbackConn=RunService.Heartbeat:Connect(function()
        if not antiRagdollEnabled then return end
        local char=LP.Character; if not char then return end
        local root=char:FindFirstChild("HumanoidRootPart")
        local hum=char:FindFirstChildOfClass("Humanoid"); if not root or not hum then return end
        local state=hum:GetState()
        if state==Enum.HumanoidStateType.Physics or state==Enum.HumanoidStateType.Ragdoll or state==Enum.HumanoidStateType.FallingDown then
            local currentVel=root.AssemblyLinearVelocity
            if math.abs(currentVel.X)>5 or math.abs(currentVel.Z)>5 then
                root.AssemblyLinearVelocity=Vector3.new(0,currentVel.Y,0)
            end
            root.AssemblyAngularVelocity=Vector3.new(0,0,0)
        end
    end)
end
local function StartAntiRagdoll()
    if antiRagdollConn then return end
    antiRagdollEnabled=true; startAntiKnockback()
    antiRagdollLoopConn=RunService.Heartbeat:Connect(function()
        if not antiRagdollEnabled then return end
        local char=LP.Character; if not char then return end
        local hum=char:FindFirstChildOfClass("Humanoid")
        local root=char:FindFirstChild("HumanoidRootPart"); if not hum then return end
        local state=hum:GetState()
        if state==Enum.HumanoidStateType.Ragdoll or state==Enum.HumanoidStateType.FallingDown or state==Enum.HumanoidStateType.Physics then
            fixRagdoll(char,hum,root)
            if workspace.CurrentCamera then workspace.CurrentCamera.CameraSubject=hum end
        end
    end)
    antiRagdollConn=RunService.Heartbeat:Connect(function()
        if not antiRagdollEnabled then return end
        local char=LP.Character; if not char then return end
        local hum=char:FindFirstChildOfClass("Humanoid")
        if hum and hum.PlatformStand then hum.PlatformStand=false end
    end)
end
local function StopAntiRagdoll()
    antiRagdollEnabled=false
    if antiRagdollConn then antiRagdollConn:Disconnect(); antiRagdollConn=nil end
    if antiRagdollLoopConn then antiRagdollLoopConn:Disconnect(); antiRagdollLoopConn=nil end
    if antiKnockbackConn then antiKnockbackConn:Disconnect(); antiKnockbackConn=nil end
end

local function startFloat()
    if FloatConn then return end
    local char=LP.Character; if not char then return end
    local hrp=char:FindFirstChild("HumanoidRootPart"); if not hrp then return end
    FloatOriginalY=hrp.Position.Y; FloatEnabled=true
    FloatConn=RunService.Heartbeat:Connect(function()
        if not FloatEnabled or not HRP then return end
        local targetY=FloatOriginalY+FloatHeight
        local curY=HRP.Position.Y
        local diff=targetY-curY
        if math.abs(diff)>0.5 then
            HRP.AssemblyLinearVelocity=Vector3.new(HRP.AssemblyLinearVelocity.X,math.clamp(diff*6,-30,30),HRP.AssemblyLinearVelocity.Z)
        else
            HRP.AssemblyLinearVelocity=Vector3.new(HRP.AssemblyLinearVelocity.X,0,HRP.AssemblyLinearVelocity.Z)
        end
    end)
end
local function stopFloat()
    FloatEnabled=false
    if FloatConn then FloatConn:Disconnect(); FloatConn=nil end
    if HRP then HRP.AssemblyLinearVelocity=Vector3.new(HRP.AssemblyLinearVelocity.X,0,HRP.AssemblyLinearVelocity.Z) end
end

local _tpStatusValue=nil; local _homeStatusLbl=nil; local _timeStatusLbl=nil
local _duelDirLbl=nil; local _duelArrowLbl=nil

local function duelUpdateTargetFromHome()
    if not duel_myHome then duel_enemySide=nil; return end
    duel_enemySide=(duel_myHome=="LEFT") and "RIGHT" or "LEFT"; DuelTP_Target=duel_enemySide
end
local function duelSaveHome()
    if not duel_myHome then return end
    pcall(function() if writefile then writefile("DuelTP_Home.json",HttpService:JSONEncode({home=duel_myHome})) end end)
end
local function duelLoadHome()
    pcall(function()
        if isfile and isfile("DuelTP_Home.json") then
            local d=HttpService:JSONDecode(readfile("DuelTP_Home.json"))
            if d and d.home then duel_myHome=d.home; duel_homeSet=true; duelUpdateTargetFromHome() end
        end
    end)
end
local function duelResetHome()
    duel_myHome=nil; duel_enemySide=nil; duel_homeSet=false
    duel_timeInZone=0; duel_currentZone=nil; DuelTP_Target="RIGHT"
    pcall(function() if isfile and isfile("DuelTP_Home.json") then delfile("DuelTP_Home.json") end end)
end
local function setTargetManual(target)
    DuelTP_Target=target; duel_enemySide=target
    if _tpStatusValue then _tpStatusValue.Text=(target=="LEFT") and "TP_L" or "TP_R" end
    if _duelDirLbl    then _duelDirLbl.Text   =(target=="LEFT") and "<- TP_L"       or "-> TP_R"      end
    if _duelArrowLbl  then _duelArrowLbl.Text =(target=="LEFT") and "N"             or "S"            end
    pcall(function() Notify("RAGDOLL TP: "..(target=="LEFT" and "TP_L" or "TP_R")) end)
end
local function duelUpdateZone(dt)
    if not homeDetectionEnabled then return end
    local char=LP.Character
    if not char then duel_timeInZone=0; duel_currentZone=nil; return end
    local hrp=char:FindFirstChild("HumanoidRootPart")
    if not hrp then duel_timeInZone=0; duel_currentZone=nil; return end
    local pos=hrp.Position; local newZone=nil
    if     (pos-DUEL_STAND_POINTS.LEFT).Magnitude <DUEL_STAND_RADIUS then newZone="LEFT"
    elseif (pos-DUEL_STAND_POINTS.RIGHT).Magnitude<DUEL_STAND_RADIUS then newZone="RIGHT" end
    if newZone==duel_currentZone then
        if newZone then duel_timeInZone=duel_timeInZone+dt end
    else duel_currentZone=newZone; duel_timeInZone=0 end
    if newZone and duel_timeInZone>=DUEL_STAND_DURATION and not duel_homeSet then
        duel_myHome=newZone; duel_homeSet=true; duelUpdateTargetFromHome(); duelSaveHome()
        pcall(function()
            StarterGui:SetCore("SendNotification",{
                Title="Home Set",
                Text="Home set! Target: "..(duel_enemySide=="LEFT" and "TP_L" or "TP_R"),
                Duration=3
            })
        end)
        pcall(function() Notify("Home set -> target: "..(duel_enemySide=="LEFT" and "TP_L" or "TP_R")) end)
    end
end
local function safeTeleport(point)
    local now=tick()
    if now-duel_lastTPTime<DUEL_TP_COOLDOWN then return false end
    local char=LP.Character; if not char then return false end
    local hrp=char:FindFirstChild("HumanoidRootPart"); if not hrp then return false end
    local oldVel=hrp.AssemblyLinearVelocity
    hrp.CFrame=CFrame.new(point); duel_lastTPTime=now
    task.wait(0.05); hrp.AssemblyLinearVelocity=oldVel
    return true
end
local function duelTeleport()
    local side=duel_enemySide or DuelTP_Target; if not side then return false end
    return safeTeleport(DUEL_TP_POINTS[side])
end

local duelTPConn=nil
local function startDuelTP()
    State.DuelTP=true; duelLoadHome()
    if duelTPConn then duelTPConn:Disconnect() end
    duelTPConn=RunService.Heartbeat:Connect(function(dt)
        if not State.DuelTP then
            if duelTPConn then duelTPConn:Disconnect(); duelTPConn=nil end; return
        end
        duelUpdateZone(dt)
        local char=LP.Character; if not char then return end
        local hrp=char:FindFirstChild("HumanoidRootPart")
        local hum=char:FindFirstChildOfClass("Humanoid"); if not hrp or not hum then return end
        local st=hum:GetState()
        if st==Enum.HumanoidStateType.Ragdoll or st==Enum.HumanoidStateType.FallingDown or st==Enum.HumanoidStateType.Physics then
            local now=tick()
            if now-duel_lastHitTime>1 then
                duel_lastHitTime=now
                local ok=duelTeleport()
                if ok then
                    if State.AutoPlayLeft  then aplPhase=1 end
                    if State.AutoPlayRight then aprPhase=1 end
                end
            end
        end
    end)
end
local function stopDuelTP()
    State.DuelTP=false
    if duelTPConn then duelTPConn:Disconnect(); duelTPConn=nil end
end

local aplConn,aprConn=nil,nil
local function getHRP2() return LP.Character and LP.Character:FindFirstChild("HumanoidRootPart") end
local function MoveTo(h,wpName,spd)
    local target=getWP(wpName); if not target then return false end
    local diff=target-h.Position
    if diff.Magnitude<1 then return true end
    h.AssemblyLinearVelocity=Vector3.new(diff.Unit.X*spd,h.AssemblyLinearVelocity.Y,diff.Unit.Z*spd)
    return false
end
local LEFT_ROUTE ={"L1","L2","L1","R1","R2"}
local RIGHT_ROUTE={"R1","R2","R1","L1","L2"}

StopAutoPlayLeft=function()
    State.AutoPlayLeft=false; if aplConn then aplConn:Disconnect(); aplConn=nil end; aplPhase=1
    local h=getHRP2(); if h then h.AssemblyLinearVelocity=Vector3.new(0,h.AssemblyLinearVelocity.Y,0) end
    if Hum then Hum.AutoRotate=true end
end
StopAutoPlayRight=function()
    State.AutoPlayRight=false; if aprConn then aprConn:Disconnect(); aprConn=nil end; aprPhase=1
    local h=getHRP2(); if h then h.AssemblyLinearVelocity=Vector3.new(0,h.AssemblyLinearVelocity.Y,0) end
    if Hum then Hum.AutoRotate=true end
end
local function updateAutoPlayLeft()
    if not State.AutoPlayLeft then return end
    local h=getHRP2(); if not h then return end
    local spd=(aplPhase<=2) and DUEL_APPROACH_SPD or DUEL_RETURN_SPD
    local target=LEFT_ROUTE[aplPhase]
    if target then if MoveTo(h,target,spd) then aplPhase=aplPhase+1 end else StopAutoPlayLeft() end
end
local function updateAutoPlayRight()
    if not State.AutoPlayRight then return end
    local h=getHRP2(); if not h then return end
    local spd=(aprPhase<=2) and DUEL_APPROACH_SPD or DUEL_RETURN_SPD
    local target=RIGHT_ROUTE[aprPhase]
    if target then if MoveTo(h,target,spd) then aprPhase=aprPhase+1 end else StopAutoPlayRight() end
end
local function StartAutoPlayLeft()
    StopAutoPlayLeft(); StopAutoPlayRight(); State.AutoPlayLeft=true; aplPhase=1
    if Hum then Hum.AutoRotate=false end
end
local function StartAutoPlayRight()
    StopAutoPlayRight(); StopAutoPlayLeft(); State.AutoPlayRight=true; aprPhase=1
    if Hum then Hum.AutoRotate=false end
end

local trackConn=nil; local trackAtt=nil; local trackLV=nil
local function cleanTrack()
    if trackLV then trackLV:Destroy(); trackLV=nil end
    if trackAtt then trackAtt:Destroy(); trackAtt=nil end
end
local function GetClosestPlayer()
    if not HRP then return nil end; local closest,best=nil,9999
    for _,p in ipairs(Players:GetPlayers()) do
        if p~=LP and p.Character then
            local r=p.Character:FindFirstChild("HumanoidRootPart")
            local hum=p.Character:FindFirstChildOfClass("Humanoid")
            if r and hum and hum.Health>0 then
                local d=(HRP.Position-r.Position).Magnitude
                if d<best then best=d; closest=r end
            end
        end
    end
    return closest
end
local function StartAutoTrack()
    State.AutoTrack=true; if trackConn then trackConn:Disconnect() end; cleanTrack()
    trackConn=RunService.Heartbeat:Connect(function()
        if not State.AutoTrack or not HRP then return end
        local target=GetClosestPlayer()
        if target then
            local dir=target.Position-HRP.Position
            local flatDir=Vector3.new(dir.X,0,dir.Z)
            if flatDir.Magnitude>1 then HRP.AssemblyLinearVelocity=flatDir.Unit*TRACK_SPEED end
        else HRP.AssemblyLinearVelocity=Vector3.new(0,HRP.AssemblyLinearVelocity.Y,0) end
    end)
end
local function StopAutoTrack()
    State.AutoTrack=false; if trackConn then trackConn:Disconnect(); trackConn=nil end; cleanTrack()
    if HRP then HRP.AssemblyLinearVelocity=Vector3.new(0,HRP.AssemblyLinearVelocity.Y,0) end
end

local jumpConn=nil
local function StartInfiniteJump()
    State.InfiniteJump=true; if jumpConn then return end
    jumpConn=UIS.JumpRequest:Connect(function()
        if not State.InfiniteJump or not HRP or not Hum then return end
        if Hum:GetState()==Enum.HumanoidStateType.Dead then return end
        local v=HRP.AssemblyLinearVelocity
        HRP.AssemblyLinearVelocity=Vector3.new(v.X,50,v.Z); speedJumpCooldown=0.3
    end)
end
local function StopInfiniteJump()
    State.InfiniteJump=false; if jumpConn then jumpConn:Disconnect(); jumpConn=nil end
end

-- Safe char reconnect (no ban risk)
LP.CharacterAdded:Connect(function(c)
    task.wait(0.2)
    local h=c:WaitForChild("Humanoid",5)
    if h then Char=c; HRP=c:FindFirstChild("HumanoidRootPart"); Hum=h end
end)

local grabBarRef={fill=nil,pct=nil,radiusLbl=nil,rateLbl=nil}
local grabMainConn=nil; local grabTimer=0; local stealCache={}
local function UpdateGrabBar(pct)
    if grabBarRef.fill      then grabBarRef.fill.Size=UDim2.new(math.clamp(pct/100,0,1),0,1,0) end
    if grabBarRef.pct       then grabBarRef.pct.Text=math.floor(pct).."%" end
    if grabBarRef.radiusLbl then grabBarRef.radiusLbl.Text=GRAB_RADIUS.."st" end
    if grabBarRef.rateLbl   then grabBarRef.rateLbl.Text=string.format("%.3f",GRAB_RATE).."s" end
end
local function IsOwnPrompt(p) return Char~=nil and p:IsDescendantOf(Char) end
local function GetPromptPos(prompt)
    local pos; pcall(function()
        local par=prompt.Parent
        if par:IsA("BasePart") then pos=par.Position
        elseif par:IsA("Attachment") then pos=par.WorldPosition
        elseif par:IsA("Model") then local pp=par.PrimaryPart or par:FindFirstChildWhichIsA("BasePart"); if pp then pos=pp.Position end
        else local bp=par:FindFirstChildWhichIsA("BasePart",true); if bp then pos=bp.Position end end
    end); return pos
end
local function buildCallbacks(prompt)
    if stealCache[prompt] then return end
    local data={holdCBs={},triggerCBs={},ready=true}
    if getconnections then
        local ok1,c1=pcall(getconnections,prompt.PromptButtonHoldBegan)
        if ok1 and type(c1)=="table" then for _,conn in ipairs(c1) do if type(conn.Function)=="function" then table.insert(data.holdCBs,conn.Function) end end end
        local ok2,c2=pcall(getconnections,prompt.Triggered)
        if ok2 and type(c2)=="table" then for _,conn in ipairs(c2) do if type(conn.Function)=="function" then table.insert(data.triggerCBs,conn.Function) end end end
    end
    if #data.holdCBs>0 or #data.triggerCBs>0 then stealCache[prompt]=data end
end
local function execSteal(prompt)
    local data=stealCache[prompt]; if not data or not data.ready then return false end
    data.ready=false
    task.spawn(function()
        for _,fn in ipairs(data.holdCBs) do task.spawn(fn) end; task.wait(0.1)
        for _,fn in ipairs(data.triggerCBs) do task.spawn(fn) end; task.wait(0.01); data.ready=true
    end); return true
end
local function firePrompt(prompt)
    local fired=false
    if fireproximityprompt then pcall(function() prompt.HoldDuration=0; fireproximityprompt(prompt,0,0); fired=true end) end
    if fired then return end
    if getconnections then
        local ok,conns=pcall(getconnections,prompt.Triggered)
        if ok and type(conns)=="table" then for _,c in ipairs(conns) do if c.Function then task.spawn(c.Function) end end; return end
    end
    pcall(function() prompt:InputHoldBegin(); task.delay(0.05,function() pcall(function() prompt:InputHoldEnd() end) end) end)
end
local function StartAutoGrab()
    State.AutoGrab=true; grabTimer=0; stealCache={}; UpdateGrabBar(0)
    if grabMainConn then grabMainConn:Disconnect() end
    grabMainConn=RunService.Heartbeat:Connect(function(dt)
        if not State.AutoGrab then grabMainConn:Disconnect(); grabMainConn=nil; UpdateGrabBar(0); return end
        if not HRP then return end
        local bestPrompt,bestDist=nil,GRAB_RADIUS
        local plots=workspace:FindFirstChild("Plots")
        if plots then
            for _,plot in pairs(plots:GetChildren()) do
                for _,desc in pairs(plot:GetDescendants()) do
                    if desc:IsA("ProximityPrompt") and desc.Enabled and not IsOwnPrompt(desc) then
                        local pos=GetPromptPos(desc)
                        if pos then local d=(HRP.Position-pos).Magnitude; if d<bestDist then bestDist=d; bestPrompt=desc end end
                    end
                end
            end
        end
        if bestPrompt then
            grabTimer=grabTimer+dt; UpdateGrabBar((grabTimer/GRAB_RATE)*100)
            if grabTimer>=GRAB_RATE then grabTimer=0; buildCallbacks(bestPrompt); if not execSteal(bestPrompt) then firePrompt(bestPrompt) end end
        else grabTimer=0; UpdateGrabBar(0) end
    end)
end
local function StopAutoGrab()
    State.AutoGrab=false; if grabMainConn then grabMainConn:Disconnect(); grabMainConn=nil end; UpdateGrabBar(0)
end

local baseOT={}; local plotConns={}; local xrayCon=nil
local function applyXray(plot)
    if baseOT[plot] then return end; baseOT[plot]={}
    for _,p in ipairs(plot:GetDescendants()) do
        if p:IsA("BasePart") and p.Transparency<0.6 then baseOT[plot][p]=p.Transparency; p.Transparency=XRAY_TRANSPARENCY end
    end
    plotConns[plot]=plot.DescendantAdded:Connect(function(d)
        if d:IsA("BasePart") and d.Transparency<0.6 then baseOT[plot][d]=d.Transparency; d.Transparency=XRAY_TRANSPARENCY end
    end)
end
local function StartXrayBase()
    State.XrayBase=true; local plots=workspace:FindFirstChild("Plots"); if not plots then return end
    for _,plot in ipairs(plots:GetChildren()) do applyXray(plot) end
    xrayCon=plots.ChildAdded:Connect(function(p) task.wait(0.2); applyXray(p) end)
end
local function StopXrayBase()
    State.XrayBase=false
    for _,conn in pairs(plotConns) do conn:Disconnect() end; plotConns={}
    if xrayCon then xrayCon:Disconnect(); xrayCon=nil end
    for _,parts in pairs(baseOT) do
        for part,orig in pairs(parts) do if part and part.Parent then part.Transparency=orig end end
    end; baseOT={}
end
local espHL={}
local function ClearESP() for _,h in pairs(espHL) do if h and h.Parent then h:Destroy() end end; espHL={} end
local function StartESP() State.ESP=true end
local function StopESP()  State.ESP=false; ClearESP() end
local function updateESP()
    if not State.ESP then return end
    for player,h in pairs(espHL) do
        if not player or not player.Character then if h and h.Parent then h:Destroy() end; espHL[player]=nil end
    end
    for _,p in ipairs(Players:GetPlayers()) do
        if p~=LP and p.Character and (not espHL[p] or not espHL[p].Parent) then
            local h=Instance.new("Highlight")
            h.FillColor=Color3.fromRGB(255,0,0); h.OutlineColor=Color3.fromRGB(255,255,255)
            h.FillTransparency=0.5; h.OutlineTransparency=0; h.Adornee=p.Character; h.Parent=p.Character
            espHL[p]=h
        end
    end
end

local antiSentryTarget=nil
local function findSentryTarget()
    local char=LP.Character; if not char or not char:FindFirstChild("HumanoidRootPart") then return end
    local rootPos=char.HumanoidRootPart.Position
    for _,obj in pairs(workspace:GetChildren()) do
        if obj.Name:find("Sentry") and not obj.Name:lower():find("bullet") then
            local ownerId=obj.Name:match("Sentry_(%d+)")
            if not (ownerId and tonumber(ownerId)==LP.UserId) then
                local part=(obj:IsA("BasePart") and obj) or (obj:IsA("Model") and (obj.PrimaryPart or obj:FindFirstChildWhichIsA("BasePart")))
                if part and (rootPos-part.Position).Magnitude<=DETECTION_DISTANCE then return obj end
            end
        end
    end
end
local function moveSentry(obj)
    local char=LP.Character; if not char or not char:FindFirstChild("HumanoidRootPart") then return end
    for _,p in pairs(obj:GetDescendants()) do if p:IsA("BasePart") then p.CanCollide=false end end
    local root=char.HumanoidRootPart; local cf=root.CFrame*CFrame.new(0,0,PULL_DISTANCE)
    if obj:IsA("BasePart") then obj.CFrame=cf
    elseif obj:IsA("Model") then local m=obj.PrimaryPart or obj:FindFirstChildWhichIsA("BasePart"); if m then m.CFrame=cf end end
end
local function getWeapon()
    local char=LP.Character; if not char then return nil end
    return LP.Backpack:FindFirstChild("Bat") or char:FindFirstChild("Bat")
end
local function attackSentry()
    local char=LP.Character; if not char then return end
    local hum=char:FindFirstChildOfClass("Humanoid"); if not hum then return end
    local weapon=getWeapon(); if not weapon then return end
    if weapon.Parent==LP.Backpack then hum:EquipTool(weapon); task.wait(0.1) end
    pcall(function() weapon:Activate() end)
    for _,r in pairs(weapon:GetDescendants()) do if r:IsA("RemoteEvent") then pcall(function() r:FireServer() end) end end
end
local function StartAntiSentry() State.AntiSentry=true end
local function StopAntiSentry()  State.AntiSentry=false; antiSentryTarget=nil end
local function updateAntiSentry()
    if not State.AntiSentry then return end
    if antiSentryTarget and antiSentryTarget.Parent==workspace then moveSentry(antiSentryTarget); attackSentry()
    else antiSentryTarget=findSentryTarget() end
end

local spinForce=nil
local function StartSpinBody()
    State.SpinBody=true; local char=LP.Character; if not char then return end
    local root=char:FindFirstChild("HumanoidRootPart"); if not root or spinForce then return end
    spinForce=Instance.new("BodyAngularVelocity"); spinForce.Name="SpinForce"
    spinForce.AngularVelocity=Vector3.new(0,SPIN_SPEED,0); spinForce.MaxTorque=Vector3.new(0,math.huge,0)
    spinForce.P=1250; spinForce.Parent=root
end
local function StopSpinBody()
    State.SpinBody=false; if spinForce then spinForce:Destroy(); spinForce=nil end
end

local gui=Instance.new("ScreenGui"); gui.Name="H2N"; gui.ResetOnSpawn=false
gui.ZIndexBehavior=Enum.ZIndexBehavior.Sibling
gui.Parent=LP:WaitForChild("PlayerGui",10)

local function createDiscordBillboard(character)
    if not character then return end; local head=character:FindFirstChild("Head"); if not head then return end
    local old=head:FindFirstChild("H2NDiscordLink"); if old then old:Destroy() end
    local billboard=Instance.new("BillboardGui"); billboard.Name="H2NDiscordLink"; billboard.Adornee=head
    billboard.Size=UDim2.new(0,200,0,40); billboard.StudsOffset=Vector3.new(0,3,0)
    billboard.AlwaysOnTop=true; billboard.LightInfluence=0; billboard.Parent=head
    local bg=Instance.new("Frame",billboard); bg.Size=UDim2.new(1,0,1,0)
    bg.BackgroundColor3=Color3.fromRGB(15,15,15); bg.BackgroundTransparency=0.2; bg.BorderSizePixel=0
    Instance.new("UICorner",bg).CornerRadius=UDim.new(0,8)
    local stroke=Instance.new("UIStroke",bg); stroke.Color=Color3.fromRGB(0,120,255); stroke.Thickness=1.5
    local lbl=Instance.new("TextLabel",bg); lbl.Size=UDim2.new(1,-10,1,0); lbl.Position=UDim2.new(0,5,0,0)
    lbl.BackgroundTransparency=1; lbl.Text="discord.gg/UeKPQC7fq"
    lbl.TextColor3=Color3.fromRGB(255,255,255); lbl.Font=Enum.Font.GothamBold; lbl.TextSize=16; lbl.TextScaled=true
end
local function setupDiscordLink(char) task.wait(0.5); createDiscordBillboard(char) end
if LP.Character then setupDiscordLink(LP.Character) end
LP.CharacterAdded:Connect(setupDiscordLink)

local stealBarFrame=Instance.new("Frame",gui); stealBarFrame.Name="StealBar"
stealBarFrame.Size=UDim2.new(0,340,0,36); stealBarFrame.Position=UDim2.new(0.5,-170,1,-55)
stealBarFrame.BackgroundColor3=Color3.fromRGB(15,0,0); stealBarFrame.ZIndex=8
stealBarFrame.Visible=StealBarVisible; stealBarFrame.Active=true
Instance.new("UICorner",stealBarFrame).CornerRadius=UDim.new(0,10)
local sbStr=Instance.new("UIStroke",stealBarFrame); sbStr.Color=Color3.fromRGB(220,0,0); sbStr.Thickness=2
do
    local sbDrag,sbDS,sbPS=false,nil,nil
    stealBarFrame.InputBegan:Connect(function(inp)
        local t=inp.UserInputType
        if t==Enum.UserInputType.MouseButton1 or t==Enum.UserInputType.Touch then sbDrag=true; sbDS=inp.Position; sbPS=stealBarFrame.Position end
    end)
    UIS.InputChanged:Connect(function(inp)
        if not sbDrag then return end
        local t=inp.UserInputType
        if t==Enum.UserInputType.MouseMovement or t==Enum.UserInputType.Touch then
            local d=inp.Position-sbDS
            stealBarFrame.Position=UDim2.new(sbPS.X.Scale,sbPS.X.Offset+d.X,sbPS.Y.Scale,sbPS.Y.Offset+d.Y)
        end
    end)
    UIS.InputEnded:Connect(function(inp)
        local t=inp.UserInputType
        if t==Enum.UserInputType.MouseButton1 or t==Enum.UserInputType.Touch then sbDrag=false end
    end)
end
local sbLabel=Instance.new("TextLabel",stealBarFrame); sbLabel.Size=UDim2.new(0,48,1,0)
sbLabel.BackgroundTransparency=1; sbLabel.Text="GRAB"; sbLabel.TextColor3=Color3.fromRGB(255,50,50)
sbLabel.Font=Enum.Font.GothamBold; sbLabel.TextSize=12; sbLabel.ZIndex=9
local sbBG=Instance.new("Frame",stealBarFrame); sbBG.Size=UDim2.new(1,-160,0,14)
sbBG.Position=UDim2.new(0,48,0.5,-7); sbBG.BackgroundColor3=Color3.fromRGB(40,0,0); sbBG.ZIndex=9
Instance.new("UICorner",sbBG).CornerRadius=UDim.new(0,6)
local sbFill=Instance.new("Frame",sbBG); sbFill.Size=UDim2.new(0,0,1,0)
sbFill.BackgroundColor3=Color3.fromRGB(255,0,0); sbFill.ZIndex=10
Instance.new("UICorner",sbFill).CornerRadius=UDim.new(0,6)
local sbPct=Instance.new("TextLabel",stealBarFrame); sbPct.Size=UDim2.new(0,34,1,0)
sbPct.Position=UDim2.new(1,-110,0,0); sbPct.BackgroundTransparency=1; sbPct.Text="0%"
sbPct.TextColor3=Color3.fromRGB(255,255,255); sbPct.Font=Enum.Font.GothamBold; sbPct.TextSize=11; sbPct.ZIndex=9
local sbRadius=Instance.new("TextLabel",stealBarFrame); sbRadius.Size=UDim2.new(0,38,1,0)
sbRadius.Position=UDim2.new(1,-76,0,0); sbRadius.BackgroundTransparency=1; sbRadius.Text=GRAB_RADIUS.."st"
sbRadius.TextColor3=Color3.fromRGB(255,160,0); sbRadius.Font=Enum.Font.GothamBold; sbRadius.TextSize=11; sbRadius.ZIndex=9
local sbRate=Instance.new("TextLabel",stealBarFrame); sbRate.Size=UDim2.new(0,50,1,0)
sbRate.Position=UDim2.new(1,-50,0,0); sbRate.BackgroundTransparency=1
sbRate.Text=string.format("%.3f",GRAB_RATE).."s"; sbRate.TextColor3=Color3.fromRGB(100,255,100)
sbRate.Font=Enum.Font.GothamBold; sbRate.TextSize=10; sbRate.ZIndex=9
grabBarRef.fill=sbFill; grabBarRef.pct=sbPct; grabBarRef.radiusLbl=sbRadius; grabBarRef.rateLbl=sbRate

local menuBtn=Instance.new("TextButton",gui); menuBtn.Size=UDim2.new(0,90,0,40)
menuBtn.Position=UDim2.new(0.5,-45,0.07,0); menuBtn.BackgroundColor3=Color3.fromRGB(15,0,0)
menuBtn.Text="H2N"; menuBtn.TextColor3=Color3.fromRGB(255,40,40)
menuBtn.Font=Enum.Font.GothamBold; menuBtn.TextSize=18; menuBtn.Active=true; menuBtn.ZIndex=10
Instance.new("UICorner",menuBtn).CornerRadius=UDim.new(0,10)
Instance.new("UIStroke",menuBtn).Color=Color3.fromRGB(220,0,0)

local activeDragBtn=nil; local dragStartBtn=nil; local dragStartPosBtn=nil
menuBtn.InputBegan:Connect(function(input)
    if input.UserInputType==Enum.UserInputType.Touch or input.UserInputType==Enum.UserInputType.MouseButton1 then
        if not activeDragBtn then activeDragBtn=input; dragStartBtn=input.Position; dragStartPosBtn=menuBtn.Position end
    end
end)
UIS.InputChanged:Connect(function(input)
    if activeDragBtn and input==activeDragBtn then
        if input.UserInputType==Enum.UserInputType.Touch or input.UserInputType==Enum.UserInputType.MouseMovement then
            local delta=input.Position-dragStartBtn
            menuBtn.Position=UDim2.new(dragStartPosBtn.X.Scale,dragStartPosBtn.X.Offset+delta.X,dragStartPosBtn.Y.Scale,dragStartPosBtn.Y.Offset+delta.Y)
        end
    end
end)
UIS.InputEnded:Connect(function(input)
    if activeDragBtn and input==activeDragBtn then activeDragBtn=nil end
end)

local menu=Instance.new("Frame",gui); menu.Size=UDim2.new(0,menuW,0,menuH)
menu.Position=UDim2.new(0.5,0,0.52,0); menu.AnchorPoint=Vector2.new(0.5,0.5)
menu.BackgroundColor3=Color3.fromRGB(10,0,0); menu.Visible=false; menu.Active=true; menu.ZIndex=9
Instance.new("UICorner",menu).CornerRadius=UDim.new(0,12)
local ms=Instance.new("UIStroke",menu); ms.Color=Color3.fromRGB(220,0,0); ms.Thickness=3

local activeDragMenu=nil; local dragStartMenu=nil; local dragStartPosMenu=nil
menu.InputBegan:Connect(function(input)
    if input.UserInputType==Enum.UserInputType.Touch or input.UserInputType==Enum.UserInputType.MouseButton1 then
        if not activeDragMenu then activeDragMenu=input; dragStartMenu=input.Position; dragStartPosMenu=menu.Position end
    end
end)
UIS.InputChanged:Connect(function(input)
    if activeDragMenu and input==activeDragMenu then
        if input.UserInputType==Enum.UserInputType.Touch or input.UserInputType==Enum.UserInputType.MouseMovement then
            local delta=input.Position-dragStartMenu
            menu.Position=UDim2.new(dragStartPosMenu.X.Scale,dragStartPosMenu.X.Offset+delta.X,dragStartPosMenu.Y.Scale,dragStartPosMenu.Y.Offset+delta.Y)
        end
    end
end)
UIS.InputEnded:Connect(function(input)
    if activeDragMenu and input==activeDragMenu then activeDragMenu=nil end
end)

menuBtn.MouseButton1Click:Connect(function() menu.Visible=not menu.Visible end)

local tl=Instance.new("TextLabel",menu); tl.Size=UDim2.new(1,-20,0,30); tl.Position=UDim2.new(0,10,0,6)
tl.BackgroundTransparency=1; tl.Text="H2N"; tl.TextColor3=Color3.fromRGB(255,40,40)
tl.Font=Enum.Font.GothamBold; tl.TextSize=17; tl.TextXAlignment=Enum.TextXAlignment.Left; tl.ZIndex=10

local tabBar=Instance.new("Frame",menu); tabBar.Size=UDim2.new(0,110,1,-44)
tabBar.Position=UDim2.new(0,8,0,40); tabBar.BackgroundColor3=Color3.fromRGB(20,0,0); tabBar.ZIndex=10
Instance.new("UICorner",tabBar).CornerRadius=UDim.new(0,10)
local tabNames={"Combat","Protect","Visual","Settings"}
local tabFrames={}; local tabBtns={}
for i,name in ipairs(tabNames) do
    local tb=Instance.new("TextButton",tabBar); tb.Size=UDim2.new(1,-12,0,38)
    tb.Position=UDim2.new(0,6,0,(i-1)*44+8); tb.BackgroundColor3=Color3.fromRGB(40,0,0)
    tb.Text=name; tb.TextColor3=Color3.fromRGB(255,40,40); tb.Font=Enum.Font.GothamBold
    tb.TextSize=14; tb.ZIndex=11; Instance.new("UICorner",tb).CornerRadius=UDim.new(0,8); tabBtns[name]=tb
    local sf=Instance.new("ScrollingFrame",menu); sf.Size=UDim2.new(1,-128,1,-44)
    sf.Position=UDim2.new(0,122,0,40); sf.BackgroundTransparency=1; sf.Visible=(i==1)
    sf.ScrollBarThickness=3; sf.ScrollBarImageColor3=Color3.fromRGB(220,0,0)
    sf.CanvasSize=UDim2.new(0,0,0,0); sf.AutomaticCanvasSize=Enum.AutomaticSize.Y; sf.ZIndex=10; tabFrames[name]=sf
    tb.MouseButton1Click:Connect(function()
        for _,f in pairs(tabFrames) do f.Visible=false end
        for _,b in pairs(tabBtns) do b.BackgroundColor3=Color3.fromRGB(40,0,0) end
        sf.Visible=true; tb.BackgroundColor3=Color3.fromRGB(130,0,0)
    end)
end
tabBtns["Combat"].BackgroundColor3=Color3.fromRGB(130,0,0)

Notify=function(txt)
    local f=Instance.new("Frame",gui); f.Size=UDim2.new(0,270,0,42)
    f.Position=UDim2.new(1,-290,1,-100); f.AnchorPoint=Vector2.new(0,1)
    f.BackgroundColor3=Color3.fromRGB(15,0,0); f.ZIndex=25
    Instance.new("UICorner",f).CornerRadius=UDim.new(0,10)
    local fs=Instance.new("UIStroke",f); fs.Color=Color3.fromRGB(220,0,0); fs.Thickness=2
    local fl=Instance.new("TextLabel",f); fl.Size=UDim2.new(1,0,1,0)
    fl.BackgroundTransparency=1; fl.Text=txt; fl.TextColor3=Color3.fromRGB(255,255,255)
    fl.Font=Enum.Font.GothamBold; fl.TextSize=14; fl.ZIndex=26
    task.spawn(function() task.wait(3); f:Destroy() end)
end

task.delay(25,function()
    homeDetectionEnabled=true
    Notify("Home detection started - stand in your zone")
end)

task.spawn(function()
    while true do task.wait(300); SaveConfig() end
end)

local function MakeToggle(parent,text,order,cb,getState)
    local row=Instance.new("Frame",parent); row.Size=UDim2.new(1,-10,0,40)
    row.Position=UDim2.new(0,5,0,order*44+4); row.BackgroundTransparency=1; row.ZIndex=11
    local lbl=Instance.new("TextLabel",row); lbl.Size=UDim2.new(0.60,0,1,0)
    lbl.BackgroundTransparency=1; lbl.Text=text; lbl.TextColor3=Color3.fromRGB(255,255,255)
    lbl.Font=Enum.Font.GothamBold; lbl.TextSize=14; lbl.TextXAlignment=Enum.TextXAlignment.Left; lbl.ZIndex=12
    local btn=Instance.new("TextButton",row); btn.Size=UDim2.new(0.34,0,0.75,0)
    btn.Position=UDim2.new(0.63,0,0.12,0); btn.BackgroundColor3=Color3.fromRGB(50,0,0)
    btn.Text="OFF"; btn.TextColor3=Color3.fromRGB(255,255,255); btn.Font=Enum.Font.GothamBold
    btn.TextSize=13; btn.ZIndex=12
    Instance.new("UICorner",btn).CornerRadius=UDim.new(0,8)
    Instance.new("UIStroke",btn).Color=Color3.fromRGB(180,0,0)
    local function R()
        if getState() then btn.Text="ON"; btn.BackgroundColor3=Color3.fromRGB(180,0,0)
        else btn.Text="OFF"; btn.BackgroundColor3=Color3.fromRGB(50,0,0) end
    end
    R(); btn.MouseButton1Click:Connect(function() cb(not getState()); R() end); return btn
end
local function MakeNumberBox(parent,text,default,order,cb)
    local row=Instance.new("Frame",parent); row.Size=UDim2.new(1,-10,0,40)
    row.Position=UDim2.new(0,5,0,order*44+4); row.BackgroundTransparency=1; row.ZIndex=11
    local lbl=Instance.new("TextLabel",row); lbl.Size=UDim2.new(0.55,0,1,0)
    lbl.BackgroundTransparency=1; lbl.Text=text; lbl.TextColor3=Color3.fromRGB(255,255,255)
    lbl.Font=Enum.Font.GothamBold; lbl.TextSize=14; lbl.TextXAlignment=Enum.TextXAlignment.Left; lbl.ZIndex=12
    local box=Instance.new("TextBox",row); box.Size=UDim2.new(0.36,0,0.75,0)
    box.Position=UDim2.new(0.60,0,0.12,0); box.BackgroundColor3=Color3.fromRGB(10,0,0)
    box.Text=tostring(default); box.TextColor3=Color3.fromRGB(255,255,255)
    box.Font=Enum.Font.GothamBold; box.TextSize=16; box.ZIndex=12
    Instance.new("UICorner",box).CornerRadius=UDim.new(0,8)
    local bs=Instance.new("UIStroke",box); bs.Color=Color3.fromRGB(220,0,0); bs.Thickness=2
    box.FocusLost:Connect(function() local n=tonumber(box.Text); if n then cb(n) else box.Text=tostring(default) end end)
    return box
end
local function MakeKeybind(parent,labelText,keyName,order)
    local row=Instance.new("Frame",parent); row.Size=UDim2.new(1,-10,0,40)
    row.Position=UDim2.new(0,5,0,order*44+4); row.BackgroundTransparency=1; row.ZIndex=11
    local lbl=Instance.new("TextLabel",row); lbl.Size=UDim2.new(0.55,0,1,0)
    lbl.BackgroundTransparency=1; lbl.Text=labelText; lbl.TextColor3=Color3.fromRGB(255,255,255)
    lbl.Font=Enum.Font.GothamBold; lbl.TextSize=14; lbl.TextXAlignment=Enum.TextXAlignment.Left; lbl.ZIndex=12
    local btn=Instance.new("TextButton",row); btn.Size=UDim2.new(0.36,0,0.75,0)
    btn.Position=UDim2.new(0.60,0,0.12,0); btn.BackgroundColor3=Color3.fromRGB(10,0,0)
    btn.Text=Keys[keyName] and Keys[keyName].Name or "?"
    btn.TextColor3=Color3.fromRGB(255,255,255); btn.Font=Enum.Font.GothamBold; btn.TextSize=12; btn.ZIndex=12
    Instance.new("UICorner",btn).CornerRadius=UDim.new(0,8)
    Instance.new("UIStroke",btn).Color=Color3.fromRGB(220,0,0)
    local listening=false; local listenConn
    btn.MouseButton1Click:Connect(function()
        if listening then return end; listening=true; btn.Text="..."; btn.BackgroundColor3=Color3.fromRGB(60,20,0)
        if listenConn then listenConn:Disconnect() end
        listenConn=UIS.InputBegan:Connect(function(input,gpe)
            if gpe then return end
            if input.UserInputType==Enum.UserInputType.Keyboard then
                Keys[keyName]=input.KeyCode; btn.Text=input.KeyCode.Name
                btn.BackgroundColor3=Color3.fromRGB(10,0,0); listening=false; listenConn:Disconnect()
                Notify("Key "..labelText.." = "..input.KeyCode.Name)
            end
        end)
    end)
end

local ci=0; local combat=tabFrames["Combat"]
MakeToggle(combat,"Auto Track",ci,function(s) if s then StartAutoTrack() else StopAutoTrack() end end,function() return State.AutoTrack end); ci=ci+1
MakeNumberBox(combat,"Track Speed",TRACK_SPEED,ci,function(v) TRACK_SPEED=math.clamp(v,10,200); Notify("Track Speed = "..TRACK_SPEED) end); ci=ci+1
MakeToggle(combat,"Auto Play Left",ci,function(s) if s then StartAutoPlayLeft() else StopAutoPlayLeft() end end,function() return State.AutoPlayLeft end); ci=ci+1
MakeToggle(combat,"Auto Play Right",ci,function(s) if s then StartAutoPlayRight() else StopAutoPlayRight() end end,function() return State.AutoPlayRight end); ci=ci+1
MakeToggle(combat,"Auto Grab",ci,function(s) if s then StartAutoGrab() else StopAutoGrab() end end,function() return State.AutoGrab end); ci=ci+1
MakeNumberBox(combat,"Grab Radius",GRAB_RADIUS,ci,function(v) GRAB_RADIUS=math.clamp(v,1,100); if grabBarRef.radiusLbl then grabBarRef.radiusLbl.Text=GRAB_RADIUS.."st" end; if State.AutoGrab then StopAutoGrab(); task.wait(0.05); StartAutoGrab() end end); ci=ci+1
MakeNumberBox(combat,"Grab Rate(s)",GRAB_RATE,ci,function(v) GRAB_RATE=math.max(v,0.001); if grabBarRef.rateLbl then grabBarRef.rateLbl.Text=string.format("%.3f",GRAB_RATE).."s" end; if State.AutoGrab then StopAutoGrab(); task.wait(0.05); StartAutoGrab() end; Notify("Grab Rate = "..string.format("%.3f",GRAB_RATE).."s") end); ci=ci+1
MakeNumberBox(combat,"Duel Approach Spd",DUEL_APPROACH_SPD,ci,function(v) DUEL_APPROACH_SPD=math.clamp(v,1,300); Notify("Approach = "..DUEL_APPROACH_SPD) end); ci=ci+1
MakeNumberBox(combat,"Duel Return Spd",DUEL_RETURN_SPD,ci,function(v) DUEL_RETURN_SPD=math.clamp(v,1,300); Notify("Return = "..DUEL_RETURN_SPD) end); ci=ci+1
MakeToggle(combat,"Anti Sentry",ci,function(s) if s then StartAntiSentry() else StopAntiSentry() end end,function() return State.AntiSentry end); ci=ci+1
MakeToggle(combat,"Spin Body",ci,function(s) if s then StartSpinBody() else StopSpinBody() end end,function() return State.SpinBody end); ci=ci+1

local pi=0; local protect=tabFrames["Protect"]
MakeToggle(protect,"Anti Ragdoll",pi,function(s) if s then StartAntiRagdoll() else StopAntiRagdoll() end end,function() return antiRagdollEnabled end); pi=pi+1
MakeToggle(protect,"Infinite Jump",pi,function(s) if s then StartInfiniteJump() else StopInfiniteJump() end end,function() return State.InfiniteJump end); pi=pi+1
MakeToggle(protect,"RAGDOLL TP",pi,function(s) if s then startDuelTP() else stopDuelTP() end end,function() return State.DuelTP end); pi=pi+1
MakeToggle(protect,"FLOAT",pi,function(s) if s then startFloat() else stopFloat() end end,function() return FloatEnabled end); pi=pi+1
MakeNumberBox(protect,"Float Height",FloatHeight,pi,function(v)
    FloatHeight=math.clamp(v,1,50)
    if FloatEnabled then local char=LP.Character; local hrp=char and char:FindFirstChild("HumanoidRootPart"); if hrp then FloatOriginalY=hrp.Position.Y end end
end); pi=pi+1

local vi=0; local visual=tabFrames["Visual"]
MakeToggle(visual,"ESP",vi,function(s) if s then StartESP() else StopESP() end end,function() return State.ESP end); vi=vi+1
MakeToggle(visual,"Xray Base",vi,function(s) if s then StartXrayBase() else StopXrayBase() end end,function() return State.XrayBase end); vi=vi+1
local hideAllState=false
MakeToggle(visual,"Hide All Side Btns",vi,function(state)
    hideAllState=state
    for _,b in pairs(gui:GetChildren()) do
        if b:IsA("Frame") and b.Name=="SideButton" then
            local id=b:GetAttribute("ID")
            if state then b.Visible=false; sideHiddenMap[id.."_all"]=true
            else if not sideHiddenMap[id.."_individual"] then b.Visible=true end; sideHiddenMap[id.."_all"]=false end
        end
    end
end,function() return hideAllState end); vi=vi+1
local sideNames={"AUTO PLAY LEFT","SPEED BOOST","AUTO PLAY RIGHT","AUTO TRACK","RAGDOLL TP"}
for _,nm in ipairs(sideNames) do
    MakeToggle(visual,"Hide "..nm,vi,function(state)
        sideHiddenMap[nm.."_individual"]=state
        for _,b in pairs(gui:GetChildren()) do
            if b:IsA("Frame") and b.Name=="SideButton" and b:GetAttribute("ID")==nm then b.Visible=not state end
        end
    end,function() return sideHiddenMap[nm.."_individual"]==true end); vi=vi+1
end
MakeToggle(visual,"Show Steal Bar",vi,function(s) StealBarVisible=s; stealBarFrame.Visible=s end,function() return StealBarVisible end); vi=vi+1
MakeNumberBox(visual,"Side Btn Size",SideButtonSize,vi,function(val) SideButtonSize=val; for _,b in pairs(gui:GetChildren()) do if b:IsA("Frame") and b.Name=="SideButton" then b.Size=UDim2.new(0,SideButtonSize,0,SideButtonSize) end end end); vi=vi+1
MakeNumberBox(visual,"Menu Width",menuW,vi,function(v) menuW=v; menu.Size=UDim2.new(0,menuW,0,menuH) end); vi=vi+1
MakeNumberBox(visual,"Menu Height",menuH,vi,function(v) menuH=v; menu.Size=UDim2.new(0,menuW,0,menuH) end); vi=vi+1

local si=0; local sTab=tabFrames["Settings"]
MakeToggle(sTab,"SPEED BOOST",si,function(s) if s then StartSpeedBoost() else StopSpeedBoost() end end,function() return State.SpeedBoost end); si=si+1
MakeToggle(sTab,"Player Speed",si,function(s) if s then StartPlayerSpeed() else StopPlayerSpeed() end end,function() return State.PlayerSpeed end); si=si+1
MakeNumberBox(sTab,"Player Spd Val",NormalSpeed,si,function(v) NormalSpeed=v end); si=si+1
MakeToggle(sTab,"Steal Speed",si,function(s) if s then StartStealSpeed() else StopStealSpeed() end end,function() return State.StealSpeed end); si=si+1
MakeNumberBox(sTab,"Steal Spd Val",StealSpeed,si,function(v) StealSpeed=v end); si=si+1
MakeNumberBox(sTab,"Track Speed",TRACK_SPEED,si,function(v) TRACK_SPEED=math.clamp(v,10,200) end); si=si+1

do
    local row1=Instance.new("Frame",sTab); row1.Size=UDim2.new(1,-10,0,40)
    row1.Position=UDim2.new(0,5,0,si*44+4); row1.BackgroundTransparency=1; row1.ZIndex=11
    local lbl1=Instance.new("TextLabel",row1); lbl1.Size=UDim2.new(0.4,0,1,0)
    lbl1.BackgroundTransparency=1; lbl1.Text="RAGDOLL TP:"; lbl1.TextColor3=Color3.fromRGB(255,255,255)
    lbl1.Font=Enum.Font.GothamBold; lbl1.TextSize=13; lbl1.TextXAlignment=Enum.TextXAlignment.Left; lbl1.ZIndex=12
    local tpSV=Instance.new("TextLabel",row1); tpSV.Size=UDim2.new(0.33,0,0.75,0)
    tpSV.Position=UDim2.new(0.38,0,0.12,0); tpSV.BackgroundColor3=Color3.fromRGB(30,0,0)
    tpSV.Text=(DuelTP_Target=="LEFT") and "TP_L" or "TP_R"
    tpSV.TextColor3=Color3.fromRGB(255,255,100); tpSV.Font=Enum.Font.GothamBold
    tpSV.TextSize=12; tpSV.TextXAlignment=Enum.TextXAlignment.Center; tpSV.ZIndex=12
    Instance.new("UICorner",tpSV).CornerRadius=UDim.new(0,6); _tpStatusValue=tpSV
    local swapMBtn=Instance.new("TextButton",row1); swapMBtn.Size=UDim2.new(0.2,0,0.75,0)
    swapMBtn.Position=UDim2.new(0.77,0,0.12,0); swapMBtn.BackgroundColor3=Color3.fromRGB(60,20,0)
    swapMBtn.Text="SWAP"; swapMBtn.TextColor3=Color3.fromRGB(255,255,255)
    swapMBtn.Font=Enum.Font.GothamBold; swapMBtn.TextSize=12; swapMBtn.BorderSizePixel=0; swapMBtn.ZIndex=12
    Instance.new("UICorner",swapMBtn).CornerRadius=UDim.new(0,6)
    Instance.new("UIStroke",swapMBtn).Color=Color3.fromRGB(220,80,0)
    swapMBtn.MouseButton1Click:Connect(function()
        setTargetManual((DuelTP_Target=="RIGHT") and "LEFT" or "RIGHT")
        swapMBtn.BackgroundColor3=Color3.fromRGB(0,80,0)
        task.delay(0.3,function() swapMBtn.BackgroundColor3=Color3.fromRGB(60,20,0) end)
    end); si=si+1

    local row2=Instance.new("Frame",sTab); row2.Size=UDim2.new(1,-10,0,40)
    row2.Position=UDim2.new(0,5,0,si*44+4); row2.BackgroundTransparency=1; row2.ZIndex=11
    -- Home status (auto set after 25s - no manual button)
    local homeLbl=Instance.new("TextLabel",row2); homeLbl.Size=UDim2.new(0.55,0,1,0)
    homeLbl.BackgroundTransparency=1; homeLbl.Text="Home: --"; homeLbl.TextColor3=Color3.fromRGB(200,200,200)
    homeLbl.Font=Enum.Font.GothamBold; homeLbl.TextSize=12; homeLbl.TextXAlignment=Enum.TextXAlignment.Left; homeLbl.ZIndex=12; _homeStatusLbl=homeLbl
    local timeLbl=Instance.new("TextLabel",row2); timeLbl.Size=UDim2.new(0.25,0,1,0)
    timeLbl.Position=UDim2.new(0.53,0,0,0); timeLbl.BackgroundTransparency=1; timeLbl.Text="--"
    timeLbl.TextColor3=Color3.fromRGB(200,200,200); timeLbl.Font=Enum.Font.Gotham
    timeLbl.TextSize=11; timeLbl.TextXAlignment=Enum.TextXAlignment.Center; timeLbl.ZIndex=12; _timeStatusLbl=timeLbl
    -- Reset button (reset home only, no set)
    local resetBtn2=Instance.new("TextButton",row2); resetBtn2.Size=UDim2.new(0.18,0,0.75,0)
    resetBtn2.Position=UDim2.new(0.8,0,0.12,0); resetBtn2.BackgroundColor3=Color3.fromRGB(80,0,0)
    resetBtn2.Text="RST"; resetBtn2.TextColor3=Color3.fromRGB(255,255,255)
    resetBtn2.Font=Enum.Font.GothamBold; resetBtn2.TextSize=11; resetBtn2.BorderSizePixel=0; resetBtn2.ZIndex=12
    Instance.new("UICorner",resetBtn2).CornerRadius=UDim.new(0,6)
    resetBtn2.MouseButton1Click:Connect(function()
        duelResetHome()
        resetBtn2.BackgroundColor3=Color3.fromRGB(0,80,0)
        task.delay(0.5,function() resetBtn2.BackgroundColor3=Color3.fromRGB(80,0,0) end)
    end); si=si+1
end

do
    local wpSep=Instance.new("TextLabel",sTab); wpSep.Size=UDim2.new(1,-10,0,20)
    wpSep.Position=UDim2.new(0,5,0,si*44+4); wpSep.BackgroundTransparency=1
    wpSep.Text="--- DUEL COORDS (L1/L2/R1/R2) ---"; wpSep.TextColor3=Color3.fromRGB(0,200,255)
    wpSep.Font=Enum.Font.GothamBold; wpSep.TextSize=12; wpSep.TextTransparency=0.2; wpSep.ZIndex=11; si=si+1
    local WPS={{name="L1",label="L1 new pos",color=Color3.fromRGB(0,120,255)},{name="L2",label="L2 new pos",color=Color3.fromRGB(0,220,255)},{name="R1",label="R1 new pos",color=Color3.fromRGB(255,130,0)},{name="R2",label="R2 new pos",color=Color3.fromRGB(255,50,50)}}
    for _,wp in ipairs(WPS) do
        local fr=Instance.new("Frame",sTab); fr.Size=UDim2.new(1,-10,0,40)
        fr.Position=UDim2.new(0,5,0,si*44+4); fr.BackgroundTransparency=1; fr.ZIndex=11
        local setBtn=Instance.new("TextButton",fr); setBtn.Size=UDim2.new(1,0,0.8,0)
        setBtn.Position=UDim2.new(0,0,0.1,0); setBtn.BackgroundColor3=Color3.fromRGB(8,8,8)
        setBtn.Font=Enum.Font.GothamBold; setBtn.TextSize=13; setBtn.TextColor3=Color3.fromRGB(255,255,255); setBtn.ZIndex=12
        Instance.new("UICorner",setBtn).CornerRadius=UDim.new(0,8)
        local bs=Instance.new("UIStroke",setBtn); bs.Color=wp.color; bs.Thickness=1.5
        local inner=Instance.new("TextLabel",setBtn); inner.Size=UDim2.new(1,-10,1,0)
        inner.Position=UDim2.new(0,10,0,0); inner.BackgroundTransparency=1
        inner.Font=Enum.Font.GothamBold; inner.TextSize=13; inner.TextColor3=Color3.fromRGB(255,255,255)
        inner.TextXAlignment=Enum.TextXAlignment.Left; inner.ZIndex=13; inner.Text=wp.label
        local wn=wp.name; local wc=wp.color; local wl=wp.label
        setBtn.MouseButton1Click:Connect(function()
            if not HRP then Notify("No character!"); return end
            local pos=HRP.Position
            if wn=="L1" then L1=pos elseif wn=="L2" then L2=pos elseif wn=="R1" then R1=pos elseif wn=="R2" then R2=pos end
            local part=WP_PARTS[wn]; if part and part.Parent then part.Position=pos else createWPPart(wn,pos,wc) end
            inner.Text=wl; setBtn.BackgroundColor3=Color3.fromRGB(0,50,0)
            task.spawn(function() task.wait(1.5); inner.Text=wl; setBtn.BackgroundColor3=Color3.fromRGB(8,8,8) end)
            Notify(wn.." set "..math.floor(pos.X)..", "..math.floor(pos.Y)..", "..math.floor(pos.Z))
        end); si=si+1
    end
end

local sep=Instance.new("TextLabel",sTab); sep.Size=UDim2.new(1,-10,0,20)
sep.Position=UDim2.new(0,5,0,si*44+4); sep.BackgroundTransparency=1
sep.Text="--------- KEYBINDS ---------"; sep.TextColor3=Color3.fromRGB(0,170,255)
sep.Font=Enum.Font.GothamBold; sep.TextSize=12; sep.TextTransparency=0.3; si=si+1
MakeKeybind(sTab,"Speed Boost Key","SpeedKey",si); si=si+1
MakeKeybind(sTab,"Inf Jump Key","InfJump",si); si=si+1
MakeKeybind(sTab,"Auto Left Key","AutoPlayLeft",si); si=si+1
MakeKeybind(sTab,"Auto Right Key","AutoPlayRight",si); si=si+1
MakeKeybind(sTab,"Auto Track Key","AutoTrack",si); si=si+1
MakeKeybind(sTab,"RAGDOLL TP Key","DuelTP",si); si=si+1

local swapKeyRow=Instance.new("Frame",sTab); swapKeyRow.Size=UDim2.new(1,-10,0,40)
swapKeyRow.Position=UDim2.new(0,5,0,si*44+4); swapKeyRow.BackgroundTransparency=1; swapKeyRow.ZIndex=11
local skl=Instance.new("TextLabel",swapKeyRow); skl.Size=UDim2.new(0.55,0,1,0)
skl.BackgroundTransparency=1; skl.Text="Swap Direction Key"; skl.TextColor3=Color3.fromRGB(255,255,255)
skl.Font=Enum.Font.GothamBold; skl.TextSize=14; skl.TextXAlignment=Enum.TextXAlignment.Left; skl.ZIndex=12
local swapKeyBtn=Instance.new("TextButton",swapKeyRow); swapKeyBtn.Size=UDim2.new(0.36,0,0.75,0)
swapKeyBtn.Position=UDim2.new(0.60,0,0.12,0); swapKeyBtn.BackgroundColor3=Color3.fromRGB(10,0,0)
swapKeyBtn.Text="X"; swapKeyBtn.TextColor3=Color3.fromRGB(255,255,255)
swapKeyBtn.Font=Enum.Font.GothamBold; swapKeyBtn.TextSize=12; swapKeyBtn.ZIndex=12
Instance.new("UICorner",swapKeyBtn).CornerRadius=UDim.new(0,8)
Instance.new("UIStroke",swapKeyBtn).Color=Color3.fromRGB(220,0,0)
local swapKeyCode=Enum.KeyCode.X; local swapListening=false; local swapListenConn
swapKeyBtn.MouseButton1Click:Connect(function()
    if swapListening then return end; swapListening=true; swapKeyBtn.Text="..."; swapKeyBtn.BackgroundColor3=Color3.fromRGB(60,20,0)
    if swapListenConn then swapListenConn:Disconnect() end
    swapListenConn=UIS.InputBegan:Connect(function(inp,gpe)
        if gpe then return end
        if inp.UserInputType==Enum.UserInputType.Keyboard then
            swapKeyCode=inp.KeyCode; swapKeyBtn.Text=inp.KeyCode.Name; swapKeyBtn.BackgroundColor3=Color3.fromRGB(10,0,0)
            swapListening=false; swapListenConn:Disconnect(); Notify("Swap Key = "..inp.KeyCode.Name)
        end
    end)
end); si=si+1

UIS.InputBegan:Connect(function(input,gpe)
    if gpe or input.UserInputType~=Enum.UserInputType.Keyboard then return end
    local k=input.KeyCode
    if k==Keys.InfJump then if State.InfiniteJump then StopInfiniteJump() else StartInfiniteJump() end
    elseif k==Keys.AutoPlayLeft then if State.AutoPlayLeft then StopAutoPlayLeft() else StartAutoPlayLeft() end
    elseif k==Keys.AutoPlayRight then if State.AutoPlayRight then StopAutoPlayRight() else StartAutoPlayRight() end
    elseif k==Keys.AutoTrack then if State.AutoTrack then StopAutoTrack() else StartAutoTrack() end
    elseif k==Keys.SpeedKey then if State.SpeedBoost then StopSpeedBoost() else StartSpeedBoost() end
    elseif k==Keys.DuelTP then if State.DuelTP then stopDuelTP() else startDuelTP() end
    elseif k==swapKeyCode then setTargetManual((DuelTP_Target=="RIGHT") and "LEFT" or "RIGHT") end
end)

local function CreateSideButton(text,side,index,getState,startFn,stopFn)
    local btn=Instance.new("Frame",gui); btn.Name="SideButton"; btn:SetAttribute("ID",text)
    btn.Size=UDim2.new(0,SideButtonSize,0,SideButtonSize); btn.BackgroundColor3=Color3.fromRGB(40,0,0)
    btn.Active=true; btn.ZIndex=5; btn.Visible=not (sideHiddenMap[text.."_individual"]==true)
    local sp=ButtonPositions[text]
    if sp and sp.XO and sp.XO>0 then btn.Position=UDim2.new(0,sp.XO,0,sp.YO)
    elseif side=="left" then btn.Position=UDim2.new(0,10,0.22+index*0.19,0)
    else btn.Position=UDim2.new(1,-(SideButtonSize+10),0.22+index*0.19,0) end
    Instance.new("UICorner",btn).CornerRadius=UDim.new(0,14)
    local stroke=Instance.new("UIStroke",btn); stroke.Color=Color3.fromRGB(220,0,0); stroke.Thickness=2
    local lbl=Instance.new("TextLabel",btn); lbl.Size=UDim2.new(1,-4,0.55,0); lbl.Position=UDim2.new(0,2,0,2)
    lbl.BackgroundTransparency=1; lbl.Text=text; lbl.TextColor3=Color3.fromRGB(255,255,255)
    lbl.Font=Enum.Font.GothamBold; lbl.TextSize=11; lbl.TextWrapped=true; lbl.ZIndex=6
    local dot=Instance.new("Frame",btn); dot.Size=UDim2.new(0,10,0,10); dot.Position=UDim2.new(0.5,-5,1,-13)
    dot.BackgroundColor3=Color3.fromRGB(80,0,0); dot.ZIndex=6; Instance.new("UICorner",dot).CornerRadius=UDim.new(1,0)
    local function RefreshVisual()
        if getState() then dot.BackgroundColor3=Color3.fromRGB(220,0,0); btn.BackgroundColor3=Color3.fromRGB(120,0,0)
        else dot.BackgroundColor3=Color3.fromRGB(80,0,0); btn.BackgroundColor3=Color3.fromRGB(40,0,0) end
    end
    local pressing,hasMoved,dragStart,btnStart,activeInput=false,false,nil,nil,nil
    btn.InputBegan:Connect(function(input)
        local t=input.UserInputType
        if t~=Enum.UserInputType.Touch and t~=Enum.UserInputType.MouseButton1 then return end
        if pressing then return end; pressing=true; hasMoved=false; activeInput=input; dragStart=input.Position; btnStart=btn.Position
    end)
    btn.InputChanged:Connect(function(input)
        if not pressing or input~=activeInput then return end
        local t=input.UserInputType
        if t~=Enum.UserInputType.Touch and t~=Enum.UserInputType.MouseMovement then return end
        if not dragStart then return end
        local delta=input.Position-dragStart
        if delta.Magnitude>6 then hasMoved=true; btn.Position=UDim2.new(btnStart.X.Scale,btnStart.X.Offset+delta.X,btnStart.Y.Scale,btnStart.Y.Offset+delta.Y) end
    end)
    btn.InputEnded:Connect(function(input)
        local t=input.UserInputType
        if t~=Enum.UserInputType.Touch and t~=Enum.UserInputType.MouseButton1 then return end
        if not pressing or input~=activeInput then return end; pressing=false; activeInput=nil
        if not hasMoved then
            task.spawn(function() btn.Size=UDim2.new(0,SideButtonSize*0.88,0,SideButtonSize*0.88); task.wait(0.07); btn.Size=UDim2.new(0,SideButtonSize,0,SideButtonSize) end)
            if getState() then stopFn() else startFn() end; RefreshVisual()
        else
            local abs=btn.AbsolutePosition
            btn.Position=UDim2.new(0,abs.X,0,abs.Y)
            ButtonPositions[text]={X=0,XO=abs.X,Y=0,YO=abs.Y}; RefreshVisual()
        end
        hasMoved=false; dragStart=nil
    end)
    RunService.RenderStepped:Connect(function() if not pressing then RefreshVisual() end end)
end

CreateSideButton("AUTO PLAY LEFT","left",0,function() return State.AutoPlayLeft end,StartAutoPlayLeft,StopAutoPlayLeft)
CreateSideButton("SPEED BOOST","left",1,function() return State.SpeedBoost end,StartSpeedBoost,StopSpeedBoost)
CreateSideButton("AUTO PLAY RIGHT","right",0,function() return State.AutoPlayRight end,StartAutoPlayRight,StopAutoPlayRight)
CreateSideButton("AUTO TRACK","right",1,function() return State.AutoTrack end,StartAutoTrack,StopAutoTrack)

do
    local bSize=SideButtonSize
    local container=Instance.new("Frame",gui); container.Name="SideButton"; container:SetAttribute("ID","RAGDOLL TP")
    container.Size=UDim2.new(0,bSize,0,bSize); container.BackgroundTransparency=1; container.Active=true; container.ZIndex=5
    container.Visible=not (sideHiddenMap["RAGDOLL TP_individual"]==true)
    local sp=ButtonPositions["RAGDOLL TP"]
    if sp and sp.XO and sp.XO>0 then container.Position=UDim2.new(0,sp.XO,0,sp.YO)
    else container.Position=UDim2.new(1,-(bSize+10),0.22+2*0.19,0) end
    local mainF=Instance.new("Frame",container); mainF.Size=UDim2.new(1,0,1,0)
    mainF.BackgroundColor3=Color3.fromRGB(40,0,0); mainF.Active=true; mainF.ZIndex=5
    Instance.new("UICorner",mainF).CornerRadius=UDim.new(0,14)
    local mStroke=Instance.new("UIStroke",mainF); mStroke.Color=Color3.fromRGB(220,0,0); mStroke.Thickness=2
    local nameLbl=Instance.new("TextLabel",mainF); nameLbl.Size=UDim2.new(1,-4,0,18); nameLbl.Position=UDim2.new(0,2,0,6)
    nameLbl.BackgroundTransparency=1; nameLbl.Text="RAGDOLL TP"; nameLbl.TextColor3=Color3.fromRGB(255,255,255)
    nameLbl.Font=Enum.Font.GothamBold; nameLbl.TextSize=11; nameLbl.ZIndex=6
    local dirLbl=Instance.new("TextLabel",mainF); dirLbl.Size=UDim2.new(1,-4,0,14); dirLbl.Position=UDim2.new(0,2,0,26)
    dirLbl.BackgroundTransparency=1; dirLbl.Text=(DuelTP_Target=="RIGHT") and "-> TP_R" or "<- TP_L"
    dirLbl.TextColor3=Color3.fromRGB(255,200,0); dirLbl.Font=Enum.Font.GothamBold; dirLbl.TextSize=11; dirLbl.ZIndex=6; _duelDirLbl=dirLbl
    local dot=Instance.new("Frame",mainF); dot.Size=UDim2.new(0,10,0,10); dot.Position=UDim2.new(0.5,-5,1,-13)
    dot.BackgroundColor3=Color3.fromRGB(80,0,0); dot.ZIndex=6; Instance.new("UICorner",dot).CornerRadius=UDim.new(1,0)
    local arrowS=math.max(math.floor(bSize*0.36),22)
    local arrowBtn=Instance.new("TextButton",container); arrowBtn.Size=UDim2.new(0,arrowS,0,arrowS)
    arrowBtn.Position=UDim2.new(1,-arrowS,1,-arrowS); arrowBtn.BackgroundColor3=Color3.fromRGB(20,10,40)
    arrowBtn.Text=(DuelTP_Target=="RIGHT") and "S" or "N"; arrowBtn.TextColor3=Color3.fromRGB(200,150,255)
    arrowBtn.Font=Enum.Font.GothamBold; arrowBtn.TextSize=math.floor(arrowS*0.55); arrowBtn.ZIndex=8
    Instance.new("UICorner",arrowBtn).CornerRadius=UDim.new(1,0)
    local arrowStroke=Instance.new("UIStroke",arrowBtn); arrowStroke.Color=Color3.fromRGB(150,80,255); arrowStroke.Thickness=2; _duelArrowLbl=arrowBtn
    arrowBtn.MouseButton1Click:Connect(function()
        setTargetManual((DuelTP_Target=="RIGHT") and "LEFT" or "RIGHT")
        arrowBtn.BackgroundColor3=Color3.fromRGB(0,80,0)
        task.delay(0.25,function() arrowBtn.BackgroundColor3=Color3.fromRGB(20,10,40) end)
    end)
    local pressing,hasMoved,dragStart,btnStart,activeIn=false,false,nil,nil,nil
    mainF.InputBegan:Connect(function(inp)
        local t=inp.UserInputType
        if t~=Enum.UserInputType.Touch and t~=Enum.UserInputType.MouseButton1 then return end
        if pressing then return end; pressing=true; hasMoved=false; activeIn=inp; dragStart=inp.Position; btnStart=container.Position
    end)
    UIS.InputChanged:Connect(function(inp)
        if not pressing or inp~=activeIn then return end
        local t=inp.UserInputType
        if t~=Enum.UserInputType.Touch and t~=Enum.UserInputType.MouseMovement then return end
        local d=inp.Position-dragStart
        if d.Magnitude>6 then
            hasMoved=true
            container.Position=UDim2.new(btnStart.X.Scale,btnStart.X.Offset+d.X,btnStart.Y.Scale,btnStart.Y.Offset+d.Y)
        end
    end)
    UIS.InputEnded:Connect(function(inp)
        local t=inp.UserInputType
        if t~=Enum.UserInputType.Touch and t~=Enum.UserInputType.MouseButton1 then return end
        if not pressing or inp~=activeIn then return end; pressing=false; activeIn=nil
        if not hasMoved then
            task.spawn(function() mainF.Size=UDim2.new(0.88,0,0.88,0); mainF.Position=UDim2.new(0.06,0,0.06,0); task.wait(0.07); mainF.Size=UDim2.new(1,0,1,0); mainF.Position=UDim2.new(0,0,0,0) end)
            if State.DuelTP then stopDuelTP() else startDuelTP() end
        else
            local abs=container.AbsolutePosition
            container.Position=UDim2.new(0,abs.X,0,abs.Y)
            ButtonPositions["RAGDOLL TP"]={X=0,XO=abs.X,Y=0,YO=abs.Y}
        end; hasMoved=false; dragStart=nil
    end)
    RunService.RenderStepped:Connect(function()
        if State.DuelTP then dot.BackgroundColor3=Color3.fromRGB(220,0,0); mainF.BackgroundColor3=Color3.fromRGB(120,0,0)
        else dot.BackgroundColor3=Color3.fromRGB(80,0,0); mainF.BackgroundColor3=Color3.fromRGB(40,0,0) end
        dirLbl.Text=(DuelTP_Target=="RIGHT") and "-> TP_R" or "<- TP_L"
        arrowBtn.Text=(DuelTP_Target=="RIGHT") and "S" or "N"
        if _homeStatusLbl then
            if duel_homeSet and duel_myHome then _homeStatusLbl.Text="Home: "..(duel_myHome=="LEFT" and "Left" or "Right"); _homeStatusLbl.TextColor3=Color3.fromRGB(100,255,100)
            else _homeStatusLbl.Text="Home: --"; _homeStatusLbl.TextColor3=Color3.fromRGB(200,200,200) end
        end
        if _timeStatusLbl then
            if duel_currentZone and not duel_homeSet then _timeStatusLbl.Text=string.format("%.1f/2.5",duel_timeInZone); _timeStatusLbl.TextColor3=Color3.fromRGB(255,255,100)
            else _timeStatusLbl.Text=duel_homeSet and "SET" or "--"; _timeStatusLbl.TextColor3=duel_homeSet and Color3.fromRGB(100,255,100) or Color3.fromRGB(200,200,200) end
        end
        if _tpStatusValue then _tpStatusValue.Text=(DuelTP_Target=="LEFT") and "TP_L" or "TP_R" end
    end)
end

RunService.Heartbeat:Connect(function(dt)
    if Hum and Char and HRP then
        if speedJumpCooldown>0 then speedJumpCooldown=speedJumpCooldown-dt end
        local hasTool=LP:GetAttribute("Stealing")==true or Char:FindFirstChildOfClass("Tool")~=nil
        local md=Hum.MoveDirection; local v=HRP.AssemblyLinearVelocity
        if not (v.Y>5 or speedJumpCooldown>0) then
            local flatMag=Vector2.new(v.X,v.Z).Magnitude
            if flatMag>350 then HRP.AssemblyLinearVelocity=Vector3.new(v.X*0.4,v.Y,v.Z*0.4)
            else
                local targetSpeed
                if State.SpeedBoost then targetSpeed=hasTool and StealSpeed or NormalSpeed
                elseif State.StealSpeed and hasTool then targetSpeed=StealSpeed
                elseif State.PlayerSpeed and not hasTool then targetSpeed=NormalSpeed
                else targetSpeed=16 end
                Hum.WalkSpeed=targetSpeed
                local flatV=Vector2.new(v.X,v.Z).Magnitude
                if md.Magnitude>0.05 and flatV<targetSpeed-5 then
                    local tX=md.X*targetSpeed; local tZ=md.Z*targetSpeed
                    lastVelX=lastVelX+(tX-lastVelX)*math.min(dt*25,1)
                    lastVelZ=lastVelZ+(tZ-lastVelZ)*math.min(dt*25,1)
                    HRP.AssemblyLinearVelocity=Vector3.new(lastVelX,v.Y,lastVelZ)
                else lastVelX=v.X; lastVelZ=v.Z end
            end
        end
    end
    if State.AutoPlayLeft  then updateAutoPlayLeft()  end
    if State.AutoPlayRight then updateAutoPlayRight() end
    if State.AntiSentry    then updateAntiSentry()    end
    if State.ESP           then updateESP()           end
end)

initWPParts()
Notify("H2N V14 - All Fixed")
Editor is loading...
Leave a Comment