Advertisement
billwa

Mortar

Jan 15th, 2016
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.95 KB | None | 0 0
  1. local mortar = Instance.new("Model", workspace)
  2. mortar.Name = "Mortar"
  3.  
  4. local leg2 = Instance.new("Part", mortar)
  5. leg2.FormFactor = Enum.FormFactor.Custom
  6. leg2.TopSurface = Enum.SurfaceType.Smooth
  7. leg2.Anchored = true
  8. leg2.Size = Vector3.new(0.3, 3, 0.3)
  9. leg2.Name = "Leg2"
  10. leg2.CFrame = CFrame.new(-35.54, 1.104, -203.893)* CFrame.Angles(2.6276757717133, -0.85311818122864, 3.0894958972931)
  11. leg2.BrickColor = BrickColor.new("Dark stone grey")
  12. leg2.Friction = 0.3
  13. leg2.BottomSurface = Enum.SurfaceType.Smooth
  14.  
  15. local launcher = Instance.new("Part", mortar)
  16. launcher.FormFactor = Enum.FormFactor.Plate
  17. launcher.CanCollide = false
  18. launcher.TopSurface = Enum.SurfaceType.Smooth
  19. launcher.Anchored = true
  20. launcher.Size = Vector3.new(4, 0.8, 1)
  21. launcher.Name = "Launcher"
  22. launcher.CFrame = CFrame.new(-35.946, 1.917, -205.107)* CFrame.Angles(0.87163752317429, 0.70191836357117, -2.2266321182251)
  23. launcher.BrickColor = BrickColor.new("Dark stone grey")
  24. launcher.Friction = 0.3
  25. launcher.BottomSurface = Enum.SurfaceType.Smooth
  26.  
  27. local mesh = Instance.new("SpecialMesh", launcher)
  28. mesh.Scale = Vector3.new(0.7, 1, 1)
  29. mesh.MeshId = "rbxasset://fonts/rocketlauncher.mesh"
  30. mesh.MeshType = Enum.MeshType.FileMesh
  31.  
  32. local fire = Instance.new("ClickDetector", launcher)
  33. fire.Name = "Fire"
  34. fire.MaxActivationDistance = 5
  35.  
  36. local explosion = Instance.new("Sound", launcher)
  37. explosion.Name = "Explosion"
  38. explosion.Volume = 1
  39. explosion.SoundId = "http://www.roblox.com/asset/?id=133680244"
  40.  
  41. local base = Instance.new("Part", mortar)
  42. base.FormFactor = Enum.FormFactor.Custom
  43. base.TopSurface = Enum.SurfaceType.Smooth
  44. base.Anchored = true
  45. base.Size = Vector3.new(3, 3, 0.2)
  46. base.Name = "Base"
  47. base.CFrame = CFrame.new(-35.61, 0.2, -204.85)* CFrame.Angles(-1.5707963705063, 0, -2.2207961082458)
  48. base.BrickColor = BrickColor.new("Dark stone grey")
  49. base.Friction = 0.3
  50. base.BottomSurface = Enum.SurfaceType.Smooth
  51.  
  52. local mesh_2 = Instance.new("SpecialMesh", base)
  53. mesh_2.Scale = Vector3.new(3, 3, 3)
  54. mesh_2.MeshId = "http://www.roblox.com/asset/?id=3270017"
  55. mesh_2.MeshType = Enum.MeshType.FileMesh
  56.  
  57. local pack = Instance.new("Part", mortar)
  58. pack.FormFactor = Enum.FormFactor.Custom
  59. pack.TopSurface = Enum.SurfaceType.Smooth
  60. pack.Anchored = true
  61. pack.Size = Vector3.new(0.6, 1, 1.25)
  62. pack.Name = "Pack"
  63. pack.CFrame = CFrame.new(-35.384, 0.6, -205.809)* CFrame.Angles(-3.139374256134, -1.2207971811295, -3.1397440433502)
  64. pack.BrickColor = BrickColor.new("Medium green")
  65. pack.Friction = 0.3
  66. pack.BottomSurface = Enum.SurfaceType.Smooth
  67.  
  68. local carry = Instance.new("ClickDetector", pack)
  69. carry.Name = "Carry"
  70. carry.MaxActivationDistance = 8
  71.  
  72. local leg = Instance.new("Part", mortar)
  73. leg.FormFactor = Enum.FormFactor.Custom
  74. leg.TopSurface = Enum.SurfaceType.Smooth
  75. leg.Anchored = true
  76. leg.Size = Vector3.new(0.3, 3, 0.3)
  77. leg.Name = "Leg"
  78. leg.CFrame = CFrame.new(-34.669, 1.104, -205.038)* CFrame.Angles(2.6276757717133, -0.85311818122864, 2.3894958496094)
  79. leg.BrickColor = BrickColor.new("Dark stone grey")
  80. leg.Friction = 0.3
  81. leg.BottomSurface = Enum.SurfaceType.Smooth
  82.  
  83. local seat = Instance.new("VehicleSeat", mortar)
  84. seat.Friction = 0.3
  85. seat.BottomSurface = Enum.SurfaceType.SteppingMotor
  86. seat.CanCollide = false
  87. seat.Transparency = 1
  88. seat.TopSurface = Enum.SurfaceType.SteppingMotor
  89. seat.CFrame = CFrame.new(-37.61, 0.325, -206.85)* CFrame.Angles(-3.1410813331604, -0.57079440355301, -3.1406464576721)
  90. seat.Size = Vector3.new(2, 1, 2)
  91. seat.FrontSurface = Enum.SurfaceType.SteppingMotor
  92. seat.Name = "Seat"
  93. seat.HeadsUpDisplay = false
  94.  
  95. local bodyposition = Instance.new("BodyPosition", seat)
  96. bodyposition.maxForce = Vector3.new(400000, 400000, 400000)
  97. bodyposition.position = Vector3.new(-37.61, 0.2, -206.85)
  98.  
  99. local bodygyro = Instance.new("BodyGyro", seat)
  100. bodygyro.maxTorque = Vector3.new(400000, 400000, 400000)
  101. bodygyro.cframe = CFrame.new(-35.61, 0.2, -204.85)* CFrame.Angles(-3.1410813331604, -0.57079607248306, -3.1406464576721)
  102.  
  103. Turn = 0
  104. Angle = 5
  105. L = mortar.Launcher
  106. B = mortar.Base
  107. Seat = mortar.Seat
  108. Ready = true
  109. Packed = false
  110. --Hit,Pos = game.Workspace:FindPartOnRay(Ray.new((Gun.CFrame*CFrame.new(0,0,-1.5)).p,(ShootTo-Gun.Position)),Gun)
  111. --CFrame.new(0,-0.5,1) * CFrame.Angles(-1.57,0,0)
  112.  
  113. function Framer()
  114. L.CFrame = ((B.CFrame * CFrame.new(0,-1.3,0.5) * CFrame.Angles(-1.57,0,1.57)) * CFrame.Angles(0,0.5+((Angle-5)*0.025),0)) * CFrame.new(-1.5,0,0)
  115. mortar.Leg.CFrame = (mortar.Base.CFrame * CFrame.new(-0.7,0.5,1.3) * CFrame.Angles(1.9,0,-0.35))* CFrame.new((Angle-5)*0.025,-(Angle-5)*0.08,0)
  116. mortar.Leg2.CFrame = (mortar.Base.CFrame * CFrame.new(0.7,0.5,1.3) * CFrame.Angles(1.9,0,0.35))* CFrame.new(-(Angle-5)*0.025,-(Angle-5)*0.08,0)
  117. mortar.Pack.CFrame = mortar.Base.CFrame * CFrame.new(-0.9,-0.4,0.4) * CFrame.Angles(1.57,0.3,-0)   
  118. end
  119.  
  120. Framer()
  121. mortar.Seat.BodyGyro.cframe = B.CFrame * CFrame.Angles(1.57,-1,0)
  122. mortar.Seat.BodyPosition.position = (B.CFrame * CFrame.new(-2,-2,0)).p
  123.  
  124. L.Fire.MouseClick:connect(function()
  125.     if Ready and not Packed then
  126.     Ready = false
  127.     Hit,Pos = game.Workspace:FindPartOnRay(Ray.new(B.CFrame * CFrame.new(0,Angle*5,150).p,((B.CFrame * CFrame.new(0,Angle*20,-250).p)-B.Position)),mortar.Launcher)
  128.     wait(0.15)
  129.     E = Instance.new("Explosion")
  130.     E.Position = Pos
  131.     E.BlastRadius = 7
  132.     E.Parent = game.Workspace
  133.     mortar.Launcher.Explosion:Play()
  134.     wait(3.5)
  135.     Ready = true
  136.     elseif Ready and Packed then
  137.         if TargetPlayer.Character.Torso.Velocity.Y < 0.25 and TargetPlayer.Character.Torso.Velocity.Y > -0.25 then
  138.         B.CFrame = TargetPlayer.Character.Torso.CFrame * CFrame.new(0,-2.8,-4) * CFrame.Angles(-1.57,0,0)
  139.         mortar.Base.Transparency = 0
  140.         mortar.Pack.Transparency = 0
  141.         mortar.Leg.Transparency = 0
  142.         mortar.Leg2.Transparency = 0
  143.         mortar.Base.CanCollide = true
  144.         mortar.Pack.CanCollide = true
  145.         mortar.Leg.CanCollide = true
  146.         mortar.Leg2.CanCollide = true
  147.         w:remove()
  148.         L.Anchored = true
  149.         Framer()
  150.         wait()
  151.         mortar.Seat.BodyGyro.cframe = B.CFrame * CFrame.Angles(1.57,-1,0)
  152.         mortar.Seat.BodyPosition.position = (B.CFrame * CFrame.new(-2,-2,0)).p
  153.         Packed = false
  154.         end
  155.     end
  156. end)
  157.  
  158. mortar.Pack.Carry.MouseClick:connect(function()
  159.     if not Packed then
  160.         if mortar.Seat:FindFirstChild("SeatWeld") == nil then
  161.         Packed = true
  162.         mortar.Base.Transparency = 1
  163.         mortar.Pack.Transparency = 1
  164.         mortar.Leg.Transparency = 1
  165.         mortar.Leg2.Transparency = 1
  166.         mortar.Base.CanCollide = false
  167.         mortar.Pack.CanCollide = false
  168.         mortar.Leg.CanCollide = false
  169.         mortar.Leg2.CanCollide = false
  170.         L.Anchored = false
  171.         Seat.BodyPosition.position = Vector3.new(0,0,0)
  172.             Dist = 8
  173.             TargetPlayer = nil
  174.             Players = game.Players:GetChildren()
  175.             for i = 1,#Players do
  176.                 if Players[i].Character ~= nil then
  177.                     if (Players[i].Character.Torso.Position-L.Position).magnitude < Dist then
  178.                     Dist = (Players[i].Character.Torso.Position-L.Position).magnitude
  179.                     TargetPlayer = Players[i]
  180.                     end
  181.                 end
  182.             end
  183.             w = Instance.new("Weld")
  184.             w.Parent = TargetPlayer.Character.Torso
  185.             w.Part0 = w.Parent
  186.             w.Part1 = L
  187.             w.C0 = CFrame.new(0.7,0.5,0.3) * CFrame.Angles(-0.3,0,1.27)
  188.         end
  189.     end
  190. end)
  191.  
  192. mortar.Seat.ChildAdded:connect(function()
  193.     mortar.Seat.SeatWeld.C0 = CFrame.new(0,-0.5,1) * CFrame.Angles(-1.57,0,0)
  194.     mortar.Seat.BodyGyro.cframe = B.CFrame * CFrame.Angles(1.57,-1,0)
  195.     mortar.Seat.BodyPosition.position = (B.CFrame * CFrame.new(-2,-2,0)).p
  196. end)
  197.  
  198. mortar.Seat.Changed:connect(function()
  199.     if Turn < 14 and Turn > -14 then
  200.     Turn = Turn + (mortar.Seat.Steer)
  201.     print(Turn)
  202.         if Turn == 14 then
  203.         Turn = 13
  204.         mortar.Base.CFrame = mortar.Base.CFrame * CFrame.Angles(0,0,mortar.Seat.Steer*0.05)
  205.         elseif Turn == -14 then
  206.         Turn = -13
  207.         mortar.Base.CFrame = mortar.Base.CFrame * CFrame.Angles(0,0,mortar.Seat.Steer*0.05)
  208.         end
  209.     mortar.Base.CFrame = mortar.Base.CFrame * CFrame.Angles(0,0,-mortar.Seat.Steer*0.05)
  210.     Framer()
  211.     end
  212.  
  213.     if Angle < 15 and Angle > 2 then
  214.     Angle = Angle + (mortar.Seat.Throttle)
  215.     print(Angle)
  216.         if Angle == 15 then
  217.         Angle = 14
  218.         elseif Angle == 2 then
  219.         Angle = 3
  220.         end
  221.     Framer()
  222.     end
  223. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement