Advertisement
SigmaBoy456

getrawmetatable Example #451

Sep 5th, 2024
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local character = player.Character
  3. local localroot = character:WaitForChild("HumanoidRootPart")
  4.  
  5. local function closest()
  6. local range = math.huge
  7. local target = nil
  8. for _, v in pairs(game.Players:GetPlayers()) do
  9. if v ~= player and v.Team ~= player.Team and v.Character then
  10. local JN = v.Character:FindFirstChild("HumanoidRootPart")
  11. if JN then
  12. local dist = (localroot.Position - JN.Position).magnitude
  13. if dist < range then
  14. range = dist
  15. target = JN
  16. end
  17. end
  18. end
  19. end
  20. return target
  21. end
  22.  
  23. local t = closest()
  24. local remote = game:GetService("Players").LocalPlayer.Character.Revolver.RevolverScript.ClientLeftDown
  25. local mt = getrawmetatable(game)
  26. setreadonly(mt, false)
  27.  
  28. local Old = mt.__namecall
  29. mt.__namecall = newcclosure(function(self, ...)
  30. local args = {...}
  31. local method = getnamecallmethod()
  32. if self == remote and method:lower() == "fireserver" and t then
  33. args[1] = t.Position
  34. return Old(self, unpack(args))
  35. end
  36. return Old(self, ...)
  37. end)
  38.  
  39. game:GetService("RunService").Heartbeat:Connect(function()
  40. t = closest()
  41. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement