Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- weapon = nil
- murder = false
- directmurder = false
- mouse = game.Players.LocalPlayer:GetMouse()
- function GetNearestNPCToMouse()
- local PLAYERS = {}
- local PLAYER_HOLD = {}
- local DISTANCES = {}
- for i, v in pairs(game.Workspace.Enemies:GetChildren()) do
- if v ~= game.Players.LocalPlayer then
- table.insert(PLAYERS, v)
- end
- end
- for i, v in pairs(PLAYERS) do
- if v.HumanoidRootPart ~= nil then
- local AIM = v:FindFirstChild("HumanoidRootPart")
- if AIM ~= nil then
- local DISTANCE = (v:FindFirstChild("HumanoidRootPart").Position - game.Workspace.CurrentCamera.CFrame.p).magnitude
- local RAY = Ray.new(game.Workspace.CurrentCamera.CFrame.p, (mouse.Hit.p - game.Workspace.CurrentCamera.CFrame.p).unit * DISTANCE)
- local HIT,POS = game.Workspace:FindPartOnRay(RAY, game.Workspace)
- local DIFF = math.floor((POS - AIM.Position).magnitude)
- PLAYER_HOLD[v.Name .. i] = {}
- PLAYER_HOLD[v.Name .. i].dist= DISTANCE
- PLAYER_HOLD[v.Name .. i].plr = v
- PLAYER_HOLD[v.Name .. i].diff = DIFF
- table.insert(DISTANCES, DIFF)
- end
- end
- end
- if unpack(DISTANCES) == nil then
- return nil
- end
- local L_DISTANCE = math.floor(math.min(unpack(DISTANCES)))
- if L_DISTANCE > 20 then
- return nil
- end
- for i, v in pairs(PLAYER_HOLD) do
- if v.diff == L_DISTANCE then
- return v.plr
- end
- end
- return nil
- end
- mouse.KeyDown:Connect(function(key)
- if key == "r" then
- murder = true
- end
- end)
- mouse.KeyUp:Connect(function(key)
- if key == "r" then
- murder = false
- end
- end)
- mouse.KeyDown:Connect(function(key)
- if key == "f" then
- murderdirect = true
- end
- end)
- mouse.KeyUp:Connect(function(key)
- if key == "f" then
- murderdirect = false
- end
- end)
- for i,v in pairs(game.Players.LocalPlayer.Character:GetChildren()) do
- if v:IsA("Model") and v:FindFirstChild("Handle") then
- weapon = v
- end
- end
- game:GetService('RunService').Stepped:connect(function()
- if murder == true then
- for i, v in pairs(game.Workspace.Enemies:GetChildren()) do
- if v:FindFirstChild("Humanoid") then
- game:GetService("ReplicatedStorage").Modules.Network.RemoteEvent:FireServer("WeaponDamage", ""..weapon.Name.."", v.Humanoid)
- end
- end
- end
- if murderdirect == true then
- for i, v in pairs(game.Workspace.Enemies:GetChildren()) do
- if v:FindFirstChild("Humanoid") then
- local NPC = GetNearestNPCToMouse()
- game:GetService("ReplicatedStorage").Modules.Network.RemoteEvent:FireServer("WeaponDamage", ""..weapon.Name.."", NPC.Humanoid)
- end
- end
- end
- end)
- --[[
- ..
- /yys. `hMM/
- :ys: `NMMMo oMMM:
- `sMMMm -oo: `NMMy
- .hMMMMM+ +MMN` `.-::. `
- -mMMyoMMN. /hho .:syhhomMMs -smNMMMNy `shysssssyhdho
- :mMMs``dMMd` NMMm .smMNdhdMMMM. `sNMNs:/MMM. `ydmmmmddMMMN+
- +NMMs -MMMs :MMM/ +NMNs- .MMMy .dMMd- -yMMy `````/hMMy-
- `yMMMmosyhdMMMM+ yMMm yMMN: `yMMM/ dMMN+odNMd/ :hMNy:
- -dMMMMMMmmdhyhMMM+ NMMo /MMM- :dMMMM- :MMMMNmho-``:/ :hNMh-
- +NMMm//-..`` `hMMMo` -MMM/ yMMm``:hNMyMMM+.-- :MMMy.` `-omMd` /dMMmo/+oooo/`
- oMMMh. `yMMMm/ :MMMs +MMMmmMNh: hMMNNNy yMMMmhdmNMm+`:dMMMMNNNNmNMMMo
- :yh+` `/dNNs `ydh: :shys/. `+yso-` :shddhy+-` oNMNho:-..```.-/`
- Join my discord here!:
- https://discord.gg/bMwYFq2
- --]]
- -- Hold R to kill all the NPCs around you
- -- Hold F to kill the closest NPC to your mouse
Add Comment
Please, Sign In to add comment