-- ==== combat helpers (uses the game's own protection systems) ==== -- protection in this game: Workspace.NewSafeZone.Zones (invisible OBB parts, Protect -- scripts hand out a "SafeField" ForceField) and Workspace.JAIL TPS (PrisZone cells). local CombatZones = {} local CombatZonesAt = 0 local function RefreshCombatZones() local List = {} local Folder = Workspace:FindFirstChild("NewSafeZone") local Zones = Folder and Folder:FindFirstChild("Zones") if Zones then for _, Part in ipairs(Zones:GetChildren()) do if Part:IsA("BasePart") then table.insert(List, Part) end end end local Jail = Workspace:FindFirstChild("JAIL TPS") if Jail then for _, Part in ipairs(Jail:GetChildren()) do if Part:IsA("BasePart") and string.find(string.lower(Part.Name), "zone", 1, true) then table.insert(List, Part) end end end CombatZones = List CombatZonesAt = os.clock() return List end local function InCombatZone(Position) if #CombatZones == 0 or os.clock() - CombatZonesAt > 60 then RefreshCombatZones() end for _, Zone in ipairs(CombatZones) do local Rel = Zone.CFrame:PointToObjectSpace(Position) local Size = Zone.Size if math.abs(Rel.X) <= Size.X * 0.5 and math.abs(Rel.Y) <= Size.Y * 0.5 and math.abs(Rel.Z) <= Size.Z * 0.5 then return true, Zone.Name end end return false end local function IsCombatGun(Tool) return Tool ~= nil and Tool:IsA("Tool") and Tool:FindFirstChild("Setting") ~= nil and Tool:FindFirstChild("GunScript_Local") ~= nil and Tool:FindFirstChild("GunScript_Server") ~= nil and Tool:FindFirstChild("Handle") ~= nil end local function CombatGun() local Char = LocalPlayer.Character if not Char then return nil end local Hum = Char:FindFirstChildOfClass("Humanoid") local Held = Char:FindFirstChildOfClass("Tool") if IsCombatGun(Held) then return Held end for _, Tool in ipairs(LocalPlayer.Backpack:GetChildren()) do if IsCombatGun(Tool) then if Hum then pcall(function() Hum:EquipTool(Tool) end) task.wait(0.2) end local Now = Char:FindFirstChildOfClass("Tool") if IsCombatGun(Now) then return Now end return nil end end return nil end -- returns ok, humanoidRootPart | reason local function CombatTarget(Plr) if typeof(Plr) ~= "Instance" or not Plr:IsA("Player") then return false, "invalid" end if Plr == LocalPlayer then return false, "self" end local Char = Plr.Character if not Char or not Char.Parent then return false, "no character" end local Hum = Char:FindFirstChildOfClass("Humanoid") local HRP = Char:FindFirstChild("HumanoidRootPart") if not (Hum and HRP) then return false, "no humanoid" end if Hum.Health <= 0 then return false, "dead" end if Char:FindFirstChild("SafeField") or Char:FindFirstChildOfClass("ForceField") then return false, "shielded" end local Inside, ZoneName = InCombatZone(HRP.Position) if Inside then return false, "safezone:" .. tostring(ZoneName) end return true, HRP end -- fires the gun the same way the game's server expects; falls back to closing the -- distance once if the first shots land nothing, gives up (and says why) otherwise local function CombatKill(Plr, Options) Options = Options or {} local MaxShots = Options.Shots or 16 local MaxTime = Options.Time or 8 local Ok, Info = CombatTarget(Plr) if not Ok then return false, Info end local Me = LocalPlayer.Character and LocalPlayer.Character:FindFirstChild("HumanoidRootPart") if not Me then return false, "no character" end if not CombatGun() then return false, "no gun" end local StartHP local LastHP local Shots = 0 local Moved = false local Started = os.clock() while os.clock() - Started < MaxTime and Shots < MaxShots do local Alive, Why = CombatTarget(Plr) if not Alive then return Why == "dead", Why end local TargetHRP = Plr.Character:FindFirstChild("HumanoidRootPart") local TargetHum = Plr.Character:FindFirstChildOfClass("Humanoid") if not (TargetHRP and TargetHum) then return true, "gone" end if StartHP == nil then StartHP = TargetHum.Health end LastHP = TargetHum.Health pcall(function() Configuration.BronxRelated.GunRemote(Configuration.BronxRelated, Plr.Name, "Head", math.huge) end) Shots = Shots + 1 task.wait(0.07) local NowHum = Plr.Character and Plr.Character:FindFirstChildOfClass("Humanoid") if not NowHum or NowHum.Health <= 0 then return true, "killed" end LastHP = NowHum.Health -- nothing landing at range: get right in front of them once and keep firing if not Moved and Shots >= 4 and LastHP >= StartHP then Moved = true FarmTeleport(TargetHRP.CFrame * CFrame.new(0, 2, 5), 5) task.wait(0.15) end end return false, string.format("no damage (%d shots, hp %.0f)", Shots, LastHP or -1) end getgenv().CorruptCombat = { RefreshZones = RefreshCombatZones, InZone = InCombatZone, Gun = CombatGun, Target = CombatTarget, Kill = CombatKill, }