Advertisement
Guest User

Untitled

a guest
Dec 11th, 2017
841
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. local Player = game.Players.LocalPlayer;
  2. local Mouse = Player:GetMouse();
  3. local MaxRange = 300;
  4. local Hotkey = Enum.KeyCode.X;
  5. local UIS = game:GetService'UserInputService';
  6. local auto = true;
  7.  
  8. function Shoot()
  9. local MyHMR = Player.Character and Player.Character.PrimaryPart;
  10. local MyData = workspace.PlayerData:FindFirstChild(Player.Name);
  11. local IsSameTeam = (MyHMR and MyHMR.Parent:FindFirstChild'CowboyHat' and true) or false;
  12. if MyHMR and MyData then
  13. for i,v in pairs(game.Players:GetPlayers()) do
  14. local HMR = v and v.Character and v.Character.PrimaryPart;
  15. local Data = workspace.PlayerData:FindFirstChild(v.Name);
  16. local Hum = HMR and v.Character:FindFirstChild'Humanoid';
  17. local Head = Hum and v.Character:FindFirstChild'Head';
  18.  
  19. if Head and Hum.Health > 0 and not (((HMR.Parent:FindFirstChild'CowboyHat' and true) or false) == IsSameTeam) then
  20. local Found = false;
  21. for ii,targ in pairs({HMR, Head}) do
  22. if not Found then
  23. local R = Ray.new(MyHMR.Position, (targ.Position-MyHMR.Position).unit*MaxRange);
  24. local P, Pos = workspace:FindPartOnRay(R, Player.Character);
  25. local p = Instance.new('Part', Player.Character);
  26. p.Anchored = true;
  27. p.Material = Enum.Material.Neon;
  28. p.CanCollide = false;
  29. p.Transparency = .5;
  30. local dist = (MyHMR.Position-Pos).magnitude;
  31. p.Size = Vector3.new(.1,.1,dist);
  32. p.CFrame = CFrame.new(MyHMR.Position, Pos)*CFrame.new(0,0,-dist/2);
  33. game:GetService('Debris'):AddItem(p, .1)
  34. if P and P:isDescendantOf(HMR.Parent) then
  35. Hum.Health = 0;
  36. local Info = {};
  37. Info.Start = MyHMR.Position;
  38. Info.HitPart = targ;
  39. Info.HitPosition = targ.Position;
  40. game.ReplicatedStorage.Events.GunFired:FireServer(Info);
  41. warn('Hit '..v.Name);
  42. Found = true;
  43. delay(1, function()
  44. if Hum and Hum.Parent then
  45. Hum.Health = 100
  46. end
  47. end)
  48. p.Color = Color3.new(0,1,0);
  49. elsse
  50. p.Color = Color3.new(1,0,0);
  51. end
  52. end
  53. end
  54. end
  55. end
  56. end
  57. end
  58. UIS.InputBegan:Connect(function(Key, GPE)
  59. if Key.KeyCode == Hotkey then
  60. Shoot();
  61. end
  62. end)
  63. spawn(function()
  64. while auto and wait(.1) do
  65. print'Shooting..';
  66. Shoot();
  67. end
  68. end)
  69. warn'Loaded!';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement