local Players = game:GetService("Players").LocalPlayer local Workspace = game:GetService("Workspace") local RunService = game:GetService("RunService") local Character = Players.Character or Players.CharacterAdded:Wait() local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart") local DamageEvent = Character.Combat.RemoteEvent local MobFolder = Workspace.NPCs local Range = 50 Players.CharacterAdded:Connect(function(newchar) Character = newchar HumanoidRootPart = newchar:WaitForChild("HumanoidRootPart") DamageEvent = newchar:WaitForChild("Combat").RemoteEvent end) local function GetWeapon() local Equipment = Character:FindFirstChild("Equipment") if not Equipment then return end for _, obj in Equipment:GetChildren() do local CharacterWeld = obj:FindFirstChild("CharacterWeld") if not CharacterWeld then continue end if CharacterWeld:FindFirstChild("SwordGrip") then return obj.Name end end end RunService.Heartbeat:Connect(function() local targets = {} local tool = GetWeapon() if not tool then return end for _, obj in MobFolder:GetChildren() do local MobRoot = obj:FindFirstChild("HumanoidRootPart") local Humanoid = obj:FindFirstChild("Humanoid") if obj:IsA("Model") and Humanoid and Humanoid.Health > 0 and MobRoot then if (HumanoidRootPart.Position - MobRoot.Position).Magnitude <= Range then table.insert(targets, MobRoot) end end end if #targets > 0 then for _, obj in targets do DamageEvent:FireServer("Input", tool, math.random(), "SlashEvent", obj) end end end)