local Players = game:GetService("Players") local LocalPlayer = Players.LocalPlayer local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait() local Root = Character:WaitForChild("HumanoidRootPart") LocalPlayer.CharacterAdded:Connect(function(char) Character = char Root = char:WaitForChild("HumanoidRootPart") end) local CombatHit = game:GetService("ReplicatedStorage") :WaitForChild("Remotes") :WaitForChild("Combat") :WaitForChild("CombatHit") local AliveFolder = workspace:WaitForChild("World"):WaitForChild("Alive") local RUN = true -- set to false to stop task.spawn(function() while RUN do local nearestTarget = nil local shortestDistance = math.huge if Root then for _, target in ipairs(AliveFolder:GetChildren()) do if target:IsA("Model") and target ~= Character and target:FindFirstChild("HumanoidRootPart") and target:FindFirstChild("Humanoid") and target.Humanoid.Health > 0 then local distance = (Root.Position - target.HumanoidRootPart.Position).Magnitude if distance < shortestDistance then shortestDistance = distance nearestTarget = target end end end end if nearestTarget then local args = { { nearestTarget }, 1 } CombatHit:FireServer(unpack(args)) end task.wait(0.01) end end)