Advertisement
SlipzYT

Strucid Zonewars

Aug 15th, 2021
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. -- vars
  2. local Players = game:GetService("Players");
  3. local Player = Players.LocalPlayer;
  4. local Mouse = Player:GetMouse();
  5. local Workspace = game:GetService("Workspace");
  6. local CurrentCam = Workspace.CurrentCamera;
  7. local require = require;
  8.  
  9. -- player func
  10. local function getClosestPlayer()
  11. local closestPlayer;
  12. local shortestDistance = math.huge;
  13.  
  14. for i, v in next, Players:GetPlayers() do
  15. if (v ~= Player and v.Character and v.Character:FindFirstChild("Head")) then
  16. local pos = CurrentCam:WorldToViewportPoint(v.Character.Head.Position);
  17. local magnitude = (Vector2.new(pos.X, pos.Y) - Vector2.new(Mouse.X, Mouse.Y)).magnitude;
  18.  
  19. if (magnitude < shortestDistance) then
  20. closestPlayer = v;
  21. shortestDistance = magnitude;
  22. end;
  23. end;
  24. end;
  25.  
  26. return closestPlayer;
  27. end;
  28.  
  29. -- main func
  30. local function run()
  31. task.wait(); -- task lib winning
  32.  
  33. local gunModule = require(Player.PlayerGui:WaitForChild("MainGui").NewLocal.Tools.Tool.Gun);
  34. local oldFunc = gunModule.ConeOfFire;
  35.  
  36. gunModule.ConeOfFire = function(...)
  37. if (getfenv(2).script.Name == "Extra") then
  38. local closePlayer = getClosestPlayer();
  39.  
  40. if (closePlayer and closePlayer.Character) then
  41. return closePlayer.Character.Head.CFrame * CFrame.new(math.random(0.1, 0.25), math.random(0.1, 0.25), math.random(0.1, 0.25)).p;
  42. end;
  43. end;
  44.  
  45. return oldFunc(...);
  46. end;
  47. end;
  48.  
  49. -- first run
  50. run();
  51.  
  52. -- epic char added
  53. Player.CharacterAdded:Connect(run);
  54.  
  55. -- made by once again the sexy beast named icee
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement