--M9 local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local LocalPlayer = Players.LocalPlayer local ShootRemote = ReplicatedStorage:WaitForChild("GunRemotes"):WaitForChild("ShootEvent") local function getClosestPlayer() local target = nil local dist = math.huge for _, v in ipairs(Players:GetPlayers()) do if v ~= LocalPlayer and v.Character and v.Character:FindFirstChild("Head") and v.Character:FindFirstChildOfClass("Humanoid") then if v.Character:FindFirstChildOfClass("Humanoid").Health > 0 then local d = (v.Character.Head.Position - workspace.CurrentCamera.CFrame.Position).Magnitude if d < dist then dist = d target = v.Character.Head end end end end return target end local function rage() local target = getClosestPlayer() if not target then return end local char = LocalPlayer.Character if not char or not char:FindFirstChild("Head") then return end local origin = char.Head.Position local hitPos = target.Position local hitPart = target local args = { { { origin, hitPos, hitPart } } } ShootRemote:FireServer(unpack(args)) end task.spawn(function() while task.wait(0.1) do rage() end end) --MP5 local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local LocalPlayer = Players.LocalPlayer local ShootRemote = ReplicatedStorage:WaitForChild("GunRemotes"):WaitForChild("ShootEvent") local function getTarget() local target = nil local lastDist = math.huge for _, v in ipairs(Players:GetPlayers()) do if v ~= LocalPlayer and v.Character and v.Character:FindFirstChild("Head") then local hum = v.Character:FindFirstChildOfClass("Humanoid") if hum and hum.Health > 0 then local dist = (v.Character.Head.Position - workspace.CurrentCamera.CFrame.Position).Magnitude if dist < lastDist then lastDist = dist target = v.Character.Head end end end end return target end local function fire() local target = getTarget() if not target then return end local char = LocalPlayer.Character local origin = char and char:FindFirstChild("Head") and char.Head.Position or workspace.CurrentCamera.CFrame.Position local args = { { { origin, target.Position, target } } } ShootRemote:FireServer(unpack(args)) end task.spawn(function() while task.wait(0.1) do fire() end end)