NotSirMeme

Untitled

Oct 21st, 2019
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. local localPlayer = game:GetService("Players").LocalPlayer
  2. local currentCamera = game:GetService("Workspace").CurrentCamera
  3. local mouse = localPlayer:GetMouse()
  4.  
  5. local function getClosestPlayerToCursor()
  6. local closestPlayer = nil
  7. local shortestDistance = math.huge
  8.  
  9. for i, v in pairs(game:GetService("Players"):GetPlayers()) do
  10. if v.Name ~= localPlayer.Name then
  11. if v.Character and v.Character:FindFirstChild("Humanoid") and v.Character.Humanoid.Health ~= 0 and v.Character:FindFirstChild("HumanoidRootPart") and v.Character:FindFirstChild("Head") then
  12. local pos = currentCamera:WorldToViewportPoint(v.Character.HumanoidRootPart.Position)
  13. local magnitude = (Vector2.new(pos.X, pos.Y) - Vector2.new(mouse.X, mouse.Y)).magnitude
  14.  
  15. if magnitude < shortestDistance then
  16. closestPlayer = v
  17. shortestDistance = magnitude
  18. end
  19. end
  20. end
  21. end
  22.  
  23. return closestPlayer or localPlayer
  24. end
  25.  
  26.  
  27. local mt = getrawmetatable(game)
  28. local oldNamecall = mt.__namecall
  29. if setreadonly then setreadonly(mt, false) else make_writeable(mt, true) end
  30. local namecallMethod = getnamecallmethod or get_namecall_method
  31. local newClose = newcclosure or function(f) return f end
  32.  
  33. mt.__namecall = newClose(function(...)
  34. local method = namecallMethod()
  35. local args = {...}
  36.  
  37. if tostring(method) == "FireServer" and tostring(args[1]) == "ThrowKnife" and getClosestPlayerToCursor() and getClosestPlayerToCursor().Character:FindFirstChild("HumanoidRootPart") then
  38. local humRootPart = getClosestPlayerToCursor().Character.HumanoidRootPart
  39. local pos = humRootPart.Position
  40. local vel = humRootPart.Velocity
  41. args[2] = pos + Vector3.new((vel.X >= 1 and 1) or (vel.X <= -1 and -1) or 0, (vel.Y >= 1 and 1) or (vel.Y <= -1 and -1) or 0, (vel.Z >= 1 and 1) or (vel.Z <= -1 and -1) or 0)
  42.  
  43. return oldNamecall(unpack(args))
  44. end
  45.  
  46. return oldNamecall(...)
  47. end)
  48.  
  49. if setreadonly then setreadonly(mt, true) else make_writeable(mt, false) end
Add Comment
Please, Sign In to add comment