Advertisement
billwa

Asswipe Rocket Launcher

Oct 30th, 2015
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.15 KB | None | 0 0
  1. asswiperockets = Instance.new("Tool",game.Players.LocalPlayer.Backpack)
  2. asswiperockets.GripPos = Vector3.new(-0.75,-0.5,0.10000000149012)
  3. asswiperockets.Grip = CFrame.new(-0.75,-0.5,0.10000000149012) * CFrame.Angles(0, 1.5707963705063, 0)
  4. asswiperockets.TextureId = "http://www.roblox.com/asset/?id=50194736"
  5. asswiperockets.GripForward = Vector3.new(-1,0,-0)
  6. asswiperockets.Name = "Asswiperockets"
  7. asswiperockets.GripRight = Vector3.new(0,0,-1)
  8.  
  9. explosion = Instance.new("Sound",asswiperockets)
  10. explosion.Name = "Explosion"
  11. explosion.Volume = 1
  12. explosion.SoundId = "rbxasset://sounds/collide.wav"
  13.  
  14. swoosh = Instance.new("Sound",asswiperockets)
  15. swoosh.Looped = true
  16. swoosh.Name = "Swoosh"
  17. swoosh.Volume = 0.69999998807907
  18. swoosh.SoundId = "rbxasset://sounds/Rocket whoosh 01.wav"
  19.  
  20. handle = Instance.new("Part",asswiperockets)
  21. handle.FormFactor = Enum.FormFactor.Plate
  22. handle.TopSurface = Enum.SurfaceType.Smooth
  23. handle.Reflectance = 0.40000000596046
  24. handle.Size = Vector3.new(4,0.80000001192093,1)
  25. handle.Name = "Handle"
  26. handle.CFrame = CFrame.new(-5.9995460510254,0.48450919985771,1.4021196365356) * CFrame.Angles(-1.5678633451462, 0.0006661856896244, 3.1412653923035)
  27. handle.BrickColor = BrickColor.new("Dark stone grey")
  28. handle.Friction = 0.30000001192093
  29. handle.BottomSurface = Enum.SurfaceType.Smooth
  30.  
  31. mesh = Instance.new("SpecialMesh",handle)
  32. mesh.Scale = Vector3.new(0.75,0.75,0.75)
  33. mesh.MeshId = "http://www.roblox.com/asset/?id=1030777"
  34. mesh.TextureId = "http://www.roblox.com/asset/?id=1030776"
  35. mesh.MeshType = Enum.MeshType.FileMesh
  36.  
  37. r = game:service("RunService")
  38.  
  39. shaft = asswiperockets
  40. position = shaft.Position
  41.  
  42. asswiperockets.Explosion.PlayOnRemove = true -- play explosion sound when projectile removed from game
  43.  
  44. function fly()
  45.     direction = asswiperockets.CFrame.lookVector
  46.     position = shaft.position + direction * 3
  47.     shaft.Velocity = 7*error
  48. end
  49.  
  50. function blow()
  51.     swoosh:stop()
  52.     explosion = Instance.new("Explosion")
  53.     explosion.Position = shaft.Position
  54.  
  55.  
  56.     -- find instigator tag
  57.     local creator = asswiperockets:findFirstChild("creator")
  58.     if creator ~= nil then
  59.         explosion.Hit:connect(function(part, distance)  onPlayerBlownUp(part, distance, creator) end)
  60.     end
  61.  
  62.     explosion.Parent = game.Workspace
  63.     connection:disconnect()
  64.     wait(.1)
  65.     shaft:remove()
  66. end
  67.  
  68. function onPlayerBlownUp(part, distance, creator)
  69.    
  70.     if part.Name == "Head" then
  71.    
  72.         local humanoid = part.Parent.Humanoid
  73.         tagHumanoid(humanoid, creator)
  74.     end
  75. end
  76.  
  77. function tagHumanoid(humanoid, creator)
  78.     -- tag does not need to expire iff all explosions lethal
  79.    
  80.     if creator ~= nil then
  81.         local new_tag = creator:clone()
  82.         new_tag.Parent = humanoid
  83.        
  84.     end
  85. end
  86.  
  87. function untagHumanoid(humanoid)
  88.     if humanoid ~= nil then
  89.         local tag = humanoid:findFirstChild("creator")
  90.         if tag ~= nil then
  91.        
  92.             tag.Parent = nil
  93.         end
  94.     end
  95. end
  96.  
  97. t, s = r.Stepped:wait()
  98.  
  99. swoosh = asswiperockets.Swoosh
  100. swoosh:play()
  101.  
  102. d = t + 10.0 - s
  103. connection = shaft.Touched:connect(blow)
  104.  
  105. while t < d do
  106.     fly()
  107.     t = r.Stepped:wait()
  108. end
  109.  
  110. -- at max range
  111. asswiperockets.Explosion.PlayOnRemove = false
  112. swoosh:stop()
  113. shaft:remove()
  114.  
  115. local Rocket = Instance.new("Part")
  116. local asswiperockets = asswiperockets
  117.  
  118. Rocket.Locked = true
  119. Rocket.BackSurface = 3
  120. Rocket.BottomSurface = 3
  121. Rocket.FrontSurface = 3
  122. Rocket.LeftSurface = 3
  123. Rocket.RightSurface = 3
  124. Rocket.TopSurface = 3
  125. Rocket.Size = Vector3.new(1,1,4)
  126. Rocket.BrickColor = BrickColor.new(6)
  127.  
  128. asswiperockets.Explosion:clone().Parent = Rocket
  129. asswiperockets.Swoosh:clone().Parent = Rocket
  130.  
  131.  
  132. function fire(vTarget, offset)
  133.  
  134.     local vCharacter = asswiperockets.Parent;
  135.    
  136.     local vHandle = asswiperockets:findFirstChild("Handle")
  137.     if vHandle == nil then
  138.         print("Handle not found")
  139.         return
  140.     end
  141.  
  142.     local dir = vTarget - vHandle.Position
  143.     dir = computeDirection(dir)
  144.     local missileCF = CFrame.new(vHandle.Position,  vHandle.Position + dir)
  145.     local missile = Rocket:clone()
  146.     local color = math.random(1,32)
  147.     missile.BrickColor = BrickColor.new(color)
  148.     print(color)
  149.     missile.CFrame = missileCF * offset
  150.  
  151.     local creator_tag = Instance.new("ObjectValue")
  152.  
  153.     local vPlayer = game.Players:playerFromCharacter(vCharacter)
  154.  
  155.     if vPlayer == nil then
  156.         print("Player not found")
  157.     else
  158.         if (vPlayer.Neutral == false) then -- nice touch
  159.             missile.BrickColor = vPlayer.TeamColor
  160.         end
  161.     end
  162.  
  163.     creator_tag.Value =vPlayer
  164.     creator_tag.Name = "creator"
  165.     creator_tag.Parent = missile
  166.  
  167.     missile.Parent = game.Workspace
  168. end
  169.  
  170. function computeDirection(vec)
  171.     local lenSquared = vec.magnitude * vec.magnitude
  172.     local invSqrt = 1 / math.sqrt(lenSquared)
  173.     return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt)
  174. end
  175.  
  176. asswiperockets.Enabled = true
  177. function onActivated()
  178.     if not asswiperockets.Enabled then
  179.         return
  180.     end
  181.  
  182.     asswiperockets.Enabled = true
  183.  
  184.     local character = asswiperockets.Parent;
  185.     local humanoid = character.Humanoid
  186.     if humanoid == nil then
  187.         print("Humanoid not found")
  188.         return
  189.     end
  190.  
  191.     local targetPos = humanoid.TargetPoint
  192.  
  193.     for i=-15,15,5 do
  194.         fire(targetPos, CFrame.new(i,0,-9))
  195.     end
  196.  
  197.     wait(0)
  198.     asswiperockets.Enabled = true
  199. end
  200.  
  201.  
  202. asswiperockets.Activated:connect(onActivated)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement