Advertisement
lafur

Untitled

Jan 18th, 2019
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. local larm = script.Parent:FindFirstChild("Left Arm")
  2. local rarm = script.Parent:FindFirstChild("Right Arm")
  3.  
  4.  
  5. function fire(spn)
  6. local missile = script.Parent.Rocket:clone()
  7. missile.CFrame = spn.CFrame * CFrame.new(0, 0, -3)
  8. missile.Delete.Disabled = false
  9.  
  10. local creator_tag = Instance.new("ObjectValue")
  11. creator_tag.Value = game.Players.LocalPlayer
  12. creator_tag.Name = "creator"
  13. creator_tag.Parent = missile
  14.  
  15. missile.RocketScript.Disabled = false
  16. missile.Parent = game.Workspace
  17. end
  18.  
  19. function findNearestTorso(pos)
  20. local list = game.Workspace:children()
  21. local torso = nil
  22. local dist = 100
  23. local temp = nil
  24. local human = nil
  25. local temp2 = nil
  26. for x = 1, #list do
  27. temp2 = list[x]
  28. if (temp2.className == "Model") and (temp2 ~= script.Parent) then
  29. temp = temp2:findFirstChild("Torso")
  30. human = temp2:findFirstChild("Humanoid")
  31. if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
  32. if (temp.Position - pos).magnitude < dist then
  33. torso = temp
  34. dist = (temp.Position - pos).magnitude
  35. end
  36. end
  37. end
  38. end
  39. return torso
  40. end
  41.  
  42. function Hit(hit)
  43. local human = hit.Parent:FindFirstChild("Humanoid")
  44. if human ~= nil then
  45. human.Health = human.Health - 100
  46. end
  47. end
  48.  
  49. larm.Touched:connect(Hit)
  50. rarm.Touched:connect(Hit)
  51.  
  52. while true do
  53. wait(0.1)
  54. local target = findNearestTorso(script.Parent.Torso.Position)
  55. if target ~= nil then
  56. script.Parent.Junk:MoveTo(target.Position, target)
  57. wait(2)
  58. fire(script.Parent:findFirstChild("Gun1"))
  59.  
  60. end
  61. end
  62. local larm = script.Parent:FindFirstChild("Left Arm")
  63. local rarm = script.Parent:FindFirstChild("Right Arm")
  64.  
  65.  
  66. function fire(spn)
  67. local missile = script.Parent.Rocket:clone()
  68. missile.CFrame = spn.CFrame * CFrame.new(0, 0, -3)
  69. missile.Delete.Disabled = false
  70.  
  71. local creator_tag = Instance.new("ObjectValue")
  72. creator_tag.Value = game.Players.LocalPlayer
  73. creator_tag.Name = "creator"
  74. creator_tag.Parent = missile
  75.  
  76. missile.RocketScript.Disabled = false
  77. missile.Parent = game.Workspace
  78. end
  79.  
  80. function findNearestTorso(pos)
  81. local list = game.Workspace:children()
  82. local torso = nil
  83. local dist = 100
  84. local temp = nil
  85. local human = nil
  86. local temp2 = nil
  87. for x = 1, #list do
  88. temp2 = list[x]
  89. if (temp2.className == "Model") and (temp2 ~= script.Parent) then
  90. temp = temp2:findFirstChild("Torso")
  91. human = temp2:findFirstChild("Humanoid")
  92. if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
  93. if (temp.Position - pos).magnitude < dist then
  94. torso = temp
  95. dist = (temp.Position - pos).magnitude
  96. end
  97. end
  98. end
  99. end
  100. return torso
  101. end
  102.  
  103. function Hit(hit)
  104. local human = hit.Parent:FindFirstChild("Humanoid")
  105. if human ~= nil then
  106. human.Health = human.Health - 100
  107. end
  108. end
  109.  
  110. larm.Touched:connect(Hit)
  111. rarm.Touched:connect(Hit)
  112.  
  113. while true do
  114. wait(0.1)
  115. local target = findNearestTorso(script.Parent.Torso.Position)
  116. if target ~= nil then
  117. script.Parent.Junk:MoveTo(target.Position, target)
  118. wait(2)
  119. fire(script.Parent:findFirstChild("Gun2"))
  120.  
  121. end
  122. end
  123. function fire(spn)
  124. local missile = script.Parent.Rocket:clone()
  125. missile.CFrame = spn.CFrame * CFrame.new(0, 0, -6)
  126.  
  127. local creator_tag = Instance.new("ObjectValue")
  128. creator_tag.Value = game.Players.LocalPlayer
  129. creator_tag.Name = "creator"
  130. creator_tag.Parent = missile
  131.  
  132. missile.RocketScript.Disabled = false
  133. missile.Parent = game.Workspace
  134. end
  135.  
  136. while true do
  137. wait(math.random(3,5))
  138. fire(script.Parent.Head)
  139. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement