Guest User

Untitled

a guest
Oct 26th, 2024
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. -- RunBullets
  2. -- TracerCalc
  3. -- Tracer
  4. -- Fire
  5. -- GetCameraLookVector
  6. local c_workspace = game:GetService("Workspace");
  7. local run_service = game:GetService("RunService");
  8. local vector2 = Vector2.new;
  9. local getinfo = debug.getinfo;
  10. local cframenew = CFrame.new;
  11. local camera = c_workspace.CurrentCamera;
  12. local closest_player = nil;
  13. local function get_closest_player()
  14. local closest, distance = nil, math.huge;
  15. for _, character in c_workspace:GetChildren() do
  16. if (character and character:FindFirstChild("Head")) then
  17. local w2s, onscreen = camera:WorldToViewportPoint(character.Head.Position);
  18. if onscreen then
  19. local dist = (vector2(w2s.X, w2s.Y) - vector2(camera.ViewportSize.X / 2, camera.ViewportSize.Y / 2)).Magnitude;
  20.  
  21. if dist < distance then
  22. closest = character;
  23. distance = dist;
  24. end
  25. end
  26. end
  27. end
  28. return closest;
  29. end
  30. run_service.RenderStepped:Connect(function()
  31. closest_player = get_closest_player();
  32. end)
  33. local old_index; old_index = hookmetamethod(game, "__index", function(self, index)
  34. local func = getinfo(3, "n");
  35. if func and func.name then
  36. if (func.name == "Fire" and index == "CFrame") and (closest_player and closest_player:FindFirstChild("Head")) then
  37. return cframenew(closest_player.Head.Position); -- gun fight arena vs the notorious cframe.new...
  38. end
  39. end
  40. return old_index(self, index);
  41. end)
Add Comment
Please, Sign In to add comment