-- Constants for easy adjustment local AVOIDANCE_DISTANCE_GEAR = 7 -- Safe distance when enemy has gear local AVOIDANCE_DISTANCE_NO_GEAR = 5 -- Safe distance when no gear local ATTACK_DISTANCE = 20 -- Distance to activate tool local DODGE_DISTANCE = 4 -- Distance to dodge when enemy attacks local STRAFE_OFFSET = 3 -- Strafing distance when close local STRAFE_SWITCH_FRAMES = 30 -- Frames before switching strafe direction -- Global variables (unchanged where specified) _G.x = nil -- Target, do not change _G.e = nil _G.rage = 0 _G.y = 0 -- Combat mode toggle _G.pos = nil local player = game.Players.LocalPlayer print("h:loaded ( :") -- Grip configurations local Grips = { Up = CFrame.new(0, 0, -1.70000005, 0, 0, 1, 1, 0, 0, 0, 1, 0), Out = CFrame.new(0, 0, -1.70000005, 0, 1, 0, 1, -0, 0, 0, 0, -1) } -- Find the closest enemy with a humanoid local function findClosestHumanoidRootPart() local closestRootPart = nil local closestDistance = math.huge local localPlayerPosition = player.Character and player.Character:FindFirstChild("HumanoidRootPart") and player.Character.HumanoidRootPart.Position if not localPlayerPosition then return nil end for _, part in pairs(workspace:GetDescendants()) do if part:IsA("BasePart") and part.Name == "HumanoidRootPart" and part.Parent ~= player.Character then local humanoid = part.Parent:FindFirstChild("Humanoid") if humanoid and humanoid.Health > 0 then local distance = (part.Position - localPlayerPosition).Magnitude if distance < closestDistance then closestDistance = distance closestRootPart = part.Parent end end end end return closestRootPart end -- Auto-targeting system local function autoTarget() local closestRootPart = findClosestHumanoidRootPart() if not closestRootPart then _G.x = nil return end if _G.x and (not _G.x:FindFirstChild("Humanoid") or _G.x.Humanoid.Health <= 0) then _G.x = nil end if _G.x then local currentDist = (_G.x.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).Magnitude local closestDist = (closestRootPart.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).Magnitude if closestRootPart ~= _G.x and closestDist < currentDist then _G.x = closestRootPart print("Switched to closer target: " .. _G.x.Name) game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", { Text = "Switched target to: " .. _G.x.Name, Color = Color3.fromRGB(0, 255, 255), Font = Enum.Font.SourceSansBold, TextSize = 18 }) end else _G.x = closestRootPart if _G.x then print("Auto-targeting: " .. _G.x.Name) game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", { Text = "Auto-targeting: " .. _G.x.Name, Color = Color3.fromRGB(0, 255, 255), Font = Enum.Font.SourceSansBold, TextSize = 18 }) end end end -- Check if enemy is holding a tool in their right hand local function isHoldingGearInRightHand(character) return character and character:FindFirstChildOfClass("Tool") ~= nil end -- Detect if enemy is attacking (sword swing) local function isEnemyAttacking(enemy) local tool = enemy and enemy:FindFirstChildOfClass("Tool") if tool then local handle = tool:FindFirstChild("Handle") if handle and handle.Velocity.Magnitude > 10 then -- Threshold for swing detection return true end end return false end -- Calculate optimal attack position (left side of enemy) local function getOptimalAttackPosition(target) if not target or not target:FindFirstChild("HumanoidRootPart") then return Vector3.new(0, 0, 0) end local targetRoot = target.HumanoidRootPart local basePosition = targetRoot.Position if isHoldingGearInRightHand(target) then return basePosition + targetRoot.CFrame.RightVector * -7 + targetRoot.CFrame.LookVector * -3 else return basePosition + targetRoot.CFrame.RightVector * -4 + targetRoot.CFrame.LookVector * -2 end end -- Setup BodyGyro and main combat loop delay(5, function() local bg = Instance.new("BodyGyro", game.ReplicatedStorage) bg.D = 1 bg.P = 30000 bg.MaxTorque = Vector3.new(400000000, 400000000, 400000000) -- Strafing variables moved outside RenderStepped for persistence local strafeCounter = 0 local strafeDirection = STRAFE_OFFSET game:GetService("RunService").RenderStepped:Connect(function() if not player.Character or player.Character.Humanoid.Health <= 0 then bg.Parent = game.ReplicatedStorage return end if _G.y == 1 and _G.x and _G.x:FindFirstChild("HumanoidRootPart") and _G.x.Humanoid.Health > 0 then bg.Parent = player.Character.HumanoidRootPart local playerRoot = player.Character.HumanoidRootPart local targetRoot = _G.x.HumanoidRootPart -- Orientation local torso = playerRoot.CFrame.p + playerRoot.CFrame.LookVector * 1 + playerRoot.CFrame.RightVector * 1 local torso2 = targetRoot.Position + targetRoot.Velocity / 10 bg.CFrame = CFrame.new(torso - Vector3.new(0, torso.y, 0), torso2 - Vector3.new(0, torso2.y, 0)) -- Base position local optimalPos = getOptimalAttackPosition(_G.x) _G.pos = optimalPos + playerRoot.CFrame.RightVector * STRAFE_OFFSET -- Adjust position based on enemy movement if targetRoot.Velocity.Magnitude > 5 then if isHoldingGearInRightHand(_G.x) then _G.pos = optimalPos + targetRoot.CFrame.RightVector * -3 + targetRoot.CFrame.LookVector * -2 - targetRoot.Velocity / 2.5 else _G.pos = targetRoot.Position + targetRoot.CFrame.RightVector * -2 + targetRoot.CFrame.LookVector * -1 - targetRoot.Velocity / 3 end end -- Strafing when close local distanceToTarget = (targetRoot.Position - playerRoot.Position).Magnitude local isClose = distanceToTarget <= 10 if isClose then _G.pos = targetRoot.Position + targetRoot.CFrame.RightVector * -3 + targetRoot.CFrame.LookVector * -1 + playerRoot.CFrame.RightVector * strafeDirection strafeCounter = strafeCounter + 1 if strafeCounter >= STRAFE_SWITCH_FRAMES then strafeDirection = -strafeDirection strafeCounter = 0 end end -- Avoidance logic local avoidancePos = targetRoot.Position if isHoldingGearInRightHand(_G.x) then local tool = _G.x:FindFirstChildOfClass("Tool") if tool and tool:FindFirstChild("Handle") then avoidancePos = tool.Handle.Position elseif _G.x:FindFirstChild("Right Arm") then avoidancePos = _G.x["Right Arm"].Position end elseif _G.x:FindFirstChild("Right Arm") then avoidancePos = _G.x["Right Arm"].Position end local safeDistance = isHoldingGearInRightHand(_G.x) and AVOIDANCE_DISTANCE_GEAR or AVOIDANCE_DISTANCE_NO_GEAR if isEnemyAttacking(_G.x) then safeDistance = safeDistance + 3 -- Increase distance during attack end local vectorToAvoid = avoidancePos - _G.pos local distanceToAvoid = vectorToAvoid.Magnitude if distanceToAvoid < safeDistance then local directionAway = (_G.pos - avoidancePos).Unit _G.pos = _G.pos + directionAway * (safeDistance - distanceToAvoid) end -- Enhanced dodge: move diagonally (backward and to the side) local vectorToPlayer = (playerRoot.Position - targetRoot.Position).Unit local enemyLookVector = targetRoot.CFrame.LookVector if enemyLookVector:Dot(vectorToPlayer) > 0.8 and isEnemyAttacking(_G.x) then local dodgeDirection = (-targetRoot.CFrame.LookVector + -targetRoot.CFrame.RightVector).Unit _G.pos = _G.pos + dodgeDirection * DODGE_DISTANCE end -- Jump if enemy is above if targetRoot.Position.y - 0.5 > playerRoot.Position.y then delay(0, function() player.Character.Humanoid.Jump = true end) end -- Attack if in range if distanceToTarget <= ATTACK_DISTANCE then local tool = player.Character:FindFirstChildOfClass("Tool") if tool then tool:Activate() end end player.Character.Humanoid:MoveTo(_G.pos) else bg.Parent = game.ReplicatedStorage _G.x = nil end end) end) -- Input handling game:GetService("UserInputService").InputBegan:Connect(function(key) if key.KeyCode == Enum.KeyCode.R then _G.y = _G.y == 1 and 0 or 1 print(_G.y == 1 and "On y" or "Off y") elseif key.KeyCode == Enum.KeyCode.T then _G.rage = _G.rage == 0 and 1 or 0 end end) -- Heartbeat for auto-targeting game:GetService("RunService").Heartbeat:Connect(function() if _G.y == 1 and _G.rage == 0 then autoTarget() end end) -- Rage mode while true do wait(0) if _G.rage == 1 and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then local point1 = player.Character.HumanoidRootPart.Position + Vector3.new(-40, -40, -40) local point2 = player.Character.HumanoidRootPart.Position + Vector3.new(40, 40, 40) local region = Region3.new(point1, point2) local parts = workspace:FindPartsInRegion3(region, player.Character, math.huge) for _, v in pairs(parts) do if v.Parent:FindFirstChild("Humanoid") and v.Parent.Humanoid.Health > 0 then print(v.Name) _G.x = v.Parent wait(0.5) break end end end end