-- discord.gg/d66H53XCsX local Players = game:GetService("Players") local Workspace = game:GetService("Workspace") local ReplicatedStorage = game:GetService("ReplicatedStorage") local LocalPlayer = Players.LocalPlayer local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait() local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart", 5) local utility = {} function utility.getEquippedTool() for _, tool in ipairs(Character:GetChildren()) do if tool:IsA("Tool") and tool:FindFirstChild("ClientWeaponState") then return tool end end return nil end function utility.getClosestNPC(maxDistance) local closestNPC, minDist = nil, maxDistance or 30 for _, obj in ipairs(Workspace:GetDescendants()) do local root = obj:FindFirstChild("HumanoidRootPart") local humanoid = obj:FindFirstChild("Humanoid") if root and humanoid and humanoid.Health > 0 and not Players:GetPlayerFromCharacter(obj) then local distance = (HumanoidRootPart.Position - root.Position).Magnitude if distance < minDist then closestNPC, minDist = humanoid, distance end end end return closestNPC end function utility.reloadWeapon(weapon, state) local ammo = state:FindFirstChild("CurrentAmmo") if ammo and ammo.Value == 0 and not state.IsReloading.Value then ReplicatedStorage.Remotes.Weapon.Reload:FireServer(Workspace:GetServerTimeNow(), weapon) repeat task.wait() until ammo.Value > 0 end end function utility.fireAtNPC(npc, weapon, state) if npc and weapon and state then local ammo = state:FindFirstChild("CurrentAmmo") if ammo and ammo.Value > 0 then ReplicatedStorage.Remotes.Weapon.Shoot:FireServer(Workspace:GetServerTimeNow(), weapon, HumanoidRootPart.CFrame, { ["1"] = npc }) end end end while task.wait(0.2) do local npc = utility.getClosestNPC(30) local weapon = utility.getEquippedTool() if weapon then local state = weapon:FindFirstChild("ClientWeaponState") if state then utility.reloadWeapon(weapon, state) utility.fireAtNPC(npc, weapon, state) end end end