crabb

MMBNCannon v0.4

Jul 19th, 2018 (edited)
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 30.02 KB | None | 0 0
  1. --[[
  2. by ages_dreamcast around 2017-ish
  3. put in startergui as a localscript
  4. press Q to fire
  5. ]]--
  6.  
  7. -- making the cannon
  8. function sandbox(var,func)
  9.     local env = getfenv(func)
  10.     local newenv = setmetatable({},{
  11.         __index = function(self,k)
  12.             if k=="script" then
  13.                 return var
  14.             else
  15.                 return env[k]
  16.             end
  17.         end,
  18.     })
  19.     setfenv(func,newenv)
  20.     return func
  21. end
  22. cors = {}
  23. mas = Instance.new("Model",game:GetService("Lighting"))
  24. Model0 = Instance.new("Model")
  25. Part1 = Instance.new("Part")
  26. Motor6D2 = Instance.new("Motor6D")
  27. Motor6D3 = Instance.new("Motor6D")
  28. Motor6D4 = Instance.new("Motor6D")
  29. Motor6D5 = Instance.new("Motor6D")
  30. Motor6D6 = Instance.new("Motor6D")
  31. Motor6D7 = Instance.new("Motor6D")
  32. Motor6D8 = Instance.new("Motor6D")
  33. Part9 = Instance.new("Part")
  34. Motor6D10 = Instance.new("Motor6D")
  35. Part11 = Instance.new("Part")
  36. Motor6D12 = Instance.new("Motor6D")
  37. Part13 = Instance.new("Part")
  38. Part14 = Instance.new("Part")
  39. Part15 = Instance.new("Part")
  40. Part16 = Instance.new("Part")
  41. Part17 = Instance.new("Part")
  42. Part18 = Instance.new("Part")
  43. WedgePart19 = Instance.new("WedgePart")
  44. Model0.Name = "cannon3"
  45. Model0.Parent = mas
  46. Part1.Name = "mid"
  47. Part1.Parent = Model0
  48. Part1.CFrame = CFrame.new(-13.025012, 6.51455927, 31.326931, -1, 0, 0, 0, 1, 0, 0, 0, -1)
  49. Part1.Orientation = Vector3.new(0, 180, 0)
  50. Part1.Position = Vector3.new(-13.025012, 6.51455927, 31.326931)
  51. Part1.Rotation = Vector3.new(-180, 0, -180)
  52. Part1.Color = Color3.new(0.180392, 0.647059, 0.180392)
  53. Part1.Size = Vector3.new(1.04464507, 0.803574085, 2.08928943)
  54. Part1.BottomSurface = Enum.SurfaceType.Smooth
  55. Part1.BrickColor = BrickColor.new("Sea green")
  56. Part1.CanCollide = false
  57. Part1.TopSurface = Enum.SurfaceType.Smooth
  58. Part1.brickColor = BrickColor.new("Sea green")
  59. Motor6D2.Parent = Part1
  60. Motor6D2.C1 = CFrame.new(7.62939453e-06, 0.522288322, 0.562496185, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  61. Motor6D2.Part0 = Part1
  62. Motor6D2.Part1 = Part18
  63. Motor6D2.part1 = Part18
  64. Motor6D3.Parent = Part1
  65. Motor6D3.C1 = CFrame.new(3.81469727e-06, 0.763356209, 0.562496185, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  66. Motor6D3.Part0 = Part1
  67. Motor6D3.Part1 = Part13
  68. Motor6D3.part1 = Part13
  69. Motor6D4.Parent = Part1
  70. Motor6D4.C1 = CFrame.new(0, 0.682994366, 0.482135773, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  71. Motor6D4.Part0 = Part1
  72. Motor6D4.Part1 = Part14
  73. Motor6D4.part1 = Part14
  74. Motor6D5.Parent = Part1
  75. Motor6D5.C1 = CFrame.new(0, -0.683033466, 0.562507629, 1, 0, 0, 0, -1, 0, 0, 0, -1)
  76. Motor6D5.Part0 = Part1
  77. Motor6D5.Part1 = WedgePart19
  78. Motor6D5.part1 = WedgePart19
  79. Motor6D6.Parent = Part1
  80. Motor6D6.C1 = CFrame.new(0, -0.401806831, 0.241065979, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  81. Motor6D6.Part0 = Part1
  82. Motor6D6.Part1 = Part17
  83. Motor6D6.part1 = Part17
  84. Motor6D7.Parent = Part1
  85. Motor6D7.C1 = CFrame.new(0, -0.401813507, 0.241065979, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  86. Motor6D7.Part0 = Part1
  87. Motor6D7.Part1 = Part16
  88. Motor6D7.part1 = Part16
  89. Motor6D8.Parent = Part1
  90. Motor6D8.C1 = CFrame.new(0, -3.52859497e-05, -1.16518402, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  91. Motor6D8.Part0 = Part1
  92. Motor6D8.Part1 = Part11
  93. Motor6D8.part1 = Part11
  94. Part9.Name = "barrelout"
  95. Part9.Parent = Model0
  96. Part9.CFrame = CFrame.new(-13.025012, 6.51459646, 29.7599716, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  97. Part9.Orientation = Vector3.new(0, -90, 0)
  98. Part9.Position = Vector3.new(-13.025012, 6.51459646, 29.7599716)
  99. Part9.Rotation = Vector3.new(0, -90, 0)
  100. Part9.Color = Color3.new(0.180392, 0.647059, 0.180392)
  101. Part9.Size = Vector3.new(0.562501252, 0.803574085, 1.04464507)
  102. Part9.BottomSurface = Enum.SurfaceType.Smooth
  103. Part9.BrickColor = BrickColor.new("Sea green")
  104. Part9.CanCollide = false
  105. Part9.TopSurface = Enum.SurfaceType.Smooth
  106. Part9.brickColor = BrickColor.new("Sea green")
  107. Part9.Shape = Enum.PartType.Cylinder
  108. Motor6D10.Parent = Part9
  109. Motor6D10.C1 = CFrame.new(0.0602722168, -2.38418579e-05, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  110. Motor6D10.Part0 = Part9
  111. Motor6D10.Part1 = Part15
  112. Motor6D10.part1 = Part15
  113. Part11.Name = "frontmid"
  114. Part11.Parent = Model0
  115. Part11.CFrame = CFrame.new(-13.025012, 6.51459455, 30.161747, -1, 0, 0, 0, 1, 0, 0, 0, -1)
  116. Part11.Orientation = Vector3.new(0, 180, 0)
  117. Part11.Position = Vector3.new(-13.025012, 6.51459455, 30.161747)
  118. Part11.Rotation = Vector3.new(-180, 0, -180)
  119. Part11.Color = Color3.new(0.121569, 0.443137, 0.121569)
  120. Part11.Size = Vector3.new(1.04464507, 0.803574085, 0.241071463)
  121. Part11.BottomSurface = Enum.SurfaceType.Smooth
  122. Part11.BrickColor = BrickColor.new("Forest green")
  123. Part11.CanCollide = false
  124. Part11.TopSurface = Enum.SurfaceType.Smooth
  125. Part11.brickColor = BrickColor.new("Forest green")
  126. Motor6D12.Parent = Part11
  127. Motor6D12.C1 = CFrame.new(0.40177536, -1.90734863e-06, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  128. Motor6D12.Part0 = Part11
  129. Motor6D12.Part1 = Part9
  130. Motor6D12.part1 = Part9
  131. Part13.Name = "bottomy"
  132. Part13.Parent = Model0
  133. Part13.CFrame = CFrame.new(-13.0250082, 5.75120306, 31.8894272, -1, 0, 0, 0, 1, 0, 0, 0, -1)
  134. Part13.Orientation = Vector3.new(0, 180, 0)
  135. Part13.Position = Vector3.new(-13.0250082, 5.75120306, 31.8894272)
  136. Part13.Rotation = Vector3.new(-180, 0, -180)
  137. Part13.Color = Color3.new(0.647059, 0.568627, 0.121569)
  138. Part13.Size = Vector3.new(1.12500238, 0.0803573132, 0.803572655)
  139. Part13.BottomSurface = Enum.SurfaceType.Smooth
  140. Part13.BrickColor = BrickColor.new("Dark Curry")
  141. Part13.CanCollide = false
  142. Part13.TopSurface = Enum.SurfaceType.Smooth
  143. Part13.brickColor = BrickColor.new("Dark Curry")
  144. Part14.Name = "bottomp"
  145. Part14.Parent = Model0
  146. Part14.CFrame = CFrame.new(-13.025012, 5.8315649, 31.8090668, -1, 0, 0, 0, 1, 0, 0, 0, -1)
  147. Part14.Orientation = Vector3.new(0, 180, 0)
  148. Part14.Position = Vector3.new(-13.025012, 5.8315649, 31.8090668)
  149. Part14.Rotation = Vector3.new(-180, 0, -180)
  150. Part14.Color = Color3.new(0.180392, 0.647059, 0.180392)
  151. Part14.Size = Vector3.new(1.04464507, 0.562502086, 1.12500203)
  152. Part14.BottomSurface = Enum.SurfaceType.Smooth
  153. Part14.BrickColor = BrickColor.new("Sea green")
  154. Part14.CanCollide = false
  155. Part14.TopSurface = Enum.SurfaceType.Smooth
  156. Part14.brickColor = BrickColor.new("Sea green")
  157. Part15.Name = "barrelin"
  158. Part15.Parent = Model0
  159. Part15.CFrame = CFrame.new(-13.025012, 6.5146203, 29.6996994, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  160. Part15.Orientation = Vector3.new(0, -90, 0)
  161. Part15.Position = Vector3.new(-13.025012, 6.5146203, 29.6996994)
  162. Part15.Rotation = Vector3.new(0, -90, 0)
  163. Part15.Color = Color3.new(0.105882, 0.164706, 0.207843)
  164. Part15.Size = Vector3.new(0.522322536, 0.562501192, 0.562501192)
  165. Part15.BottomSurface = Enum.SurfaceType.Smooth
  166. Part15.BrickColor = BrickColor.new("Black")
  167. Part15.CanCollide = false
  168. Part15.TopSurface = Enum.SurfaceType.Smooth
  169. Part15.brickColor = BrickColor.new("Black")
  170. Part15.Shape = Enum.PartType.Cylinder
  171. Part16.Name = "incirc"
  172. Part16.Parent = Model0
  173. Part16.CFrame = CFrame.new(-13.025012, 6.91637278, 31.567997, -1, 0, 0, 0, 1, 0, 0, 0, -1)
  174. Part16.Orientation = Vector3.new(0, 180, 0)
  175. Part16.Position = Vector3.new(-13.025012, 6.91637278, 31.567997)
  176. Part16.Rotation = Vector3.new(-180, 0, -180)
  177. Part16.Color = Color3.new(0.647059, 0.568627, 0.121569)
  178. Part16.Size = Vector3.new(1.12500238, 1.28571701, 1.12500238)
  179. Part16.BottomSurface = Enum.SurfaceType.Smooth
  180. Part16.BrickColor = BrickColor.new("Dark Curry")
  181. Part16.CanCollide = false
  182. Part16.TopSurface = Enum.SurfaceType.Smooth
  183. Part16.brickColor = BrickColor.new("Dark Curry")
  184. Part16.Shape = Enum.PartType.Cylinder
  185. Part17.Name = "outcirc"
  186. Part17.Parent = Model0
  187. Part17.CFrame = CFrame.new(-13.025012, 6.9163661, 31.567997, -1, 0, 0, 0, 1, 0, 0, 0, -1)
  188. Part17.Orientation = Vector3.new(0, 180, 0)
  189. Part17.Position = Vector3.new(-13.025012, 6.9163661, 31.567997)
  190. Part17.Rotation = Vector3.new(-180, 0, -180)
  191. Part17.Color = Color3.new(0.180392, 0.647059, 0.180392)
  192. Part17.Size = Vector3.new(1.04464507, 1.76786184, 1.60714626)
  193. Part17.BottomSurface = Enum.SurfaceType.Smooth
  194. Part17.BrickColor = BrickColor.new("Sea green")
  195. Part17.CanCollide = false
  196. Part17.TopSurface = Enum.SurfaceType.Smooth
  197. Part17.brickColor = BrickColor.new("Sea green")
  198. Part17.Shape = Enum.PartType.Cylinder
  199. Part18.Name = "topy"
  200. Part18.Parent = Model0
  201. Part18.CFrame = CFrame.new(-13.0250044, 5.99227095, 31.8894272, -1, 0, 0, 0, 1, 0, 0, 0, -1)
  202. Part18.Orientation = Vector3.new(0, 180, 0)
  203. Part18.Position = Vector3.new(-13.0250044, 5.99227095, 31.8894272)
  204. Part18.Rotation = Vector3.new(-180, 0, -180)
  205. Part18.Color = Color3.new(0.647059, 0.568627, 0.121569)
  206. Part18.Size = Vector3.new(1.12500238, 0.0803573132, 0.803572655)
  207. Part18.BottomSurface = Enum.SurfaceType.Smooth
  208. Part18.BrickColor = BrickColor.new("Dark Curry")
  209. Part18.CanCollide = false
  210. Part18.TopSurface = Enum.SurfaceType.Smooth
  211. Part18.brickColor = BrickColor.new("Dark Curry")
  212. WedgePart19.Name = "bottomw"
  213. WedgePart19.Parent = Model0
  214. WedgePart19.CFrame = CFrame.new(-13.025012, 5.8315258, 30.7644234, -1, 0, 0, 0, -1, 0, 0, 0, 1)
  215. WedgePart19.Orientation = Vector3.new(0, 0, 180)
  216. WedgePart19.Position = Vector3.new(-13.025012, 5.8315258, 30.7644234)
  217. WedgePart19.Rotation = Vector3.new(0, 0, -180)
  218. WedgePart19.Color = Color3.new(0.180392, 0.647059, 0.180392)
  219. WedgePart19.Size = Vector3.new(1.04464507, 0.562501132, 0.964287579)
  220. WedgePart19.BottomSurface = Enum.SurfaceType.Smooth
  221. WedgePart19.BrickColor = BrickColor.new("Sea green")
  222. WedgePart19.CanCollide = false
  223. WedgePart19.brickColor = BrickColor.new("Sea green")
  224. for i,v in pairs(mas:GetChildren()) do
  225.     v.Parent = game:GetService("Players").LocalPlayer.Character
  226.     pcall(function() v:MakeJoints() end)
  227. end
  228. mas:Destroy()
  229. for i,v in pairs(cors) do
  230.     spawn(function()
  231.         pcall(v)
  232.     end)
  233. end
  234.  
  235. function sandbox(var,func)
  236.     local env = getfenv(func)
  237.     local newenv = setmetatable({},{
  238.         __index = function(self,k)
  239.             if k=="script" then
  240.                 return var
  241.             else
  242.                 return env[k]
  243.             end
  244.         end,
  245.     })
  246.     setfenv(func,newenv)
  247.     return func
  248. end
  249. cors = {}
  250. mas3 = Instance.new("Model",game:GetService("Lighting"))
  251. BillboardGui0 = Instance.new("BillboardGui")
  252. Frame1 = Instance.new("Frame")
  253. TextLabel2 = Instance.new("TextLabel")
  254. BillboardGui0.Parent = mas3
  255. BillboardGui0.Name = "damagegui"
  256. BillboardGui0.LightInfluence = 1
  257. BillboardGui0.Size = UDim2.new(0, 200, 0, 50)
  258. BillboardGui0.ClipsDescendants = true
  259. BillboardGui0.MaxDistance = 200
  260. BillboardGui0.StudsOffset = Vector3.new(0, 3.5, 0)
  261. Frame1.Parent = BillboardGui0
  262. Frame1.Size = UDim2.new(1, 0, 1, 0)
  263. Frame1.BackgroundColor = BrickColor.new("Institutional white")
  264. Frame1.BackgroundColor3 = Color3.new(1, 1, 1)
  265. Frame1.BackgroundTransparency = 1
  266. TextLabel2.Parent = Frame1
  267. TextLabel2.Size = UDim2.new(1, 0, 1, 0)
  268. TextLabel2.BackgroundColor = BrickColor.new("Institutional white")
  269. TextLabel2.BackgroundColor3 = Color3.new(1, 1, 1)
  270. TextLabel2.BackgroundTransparency = 1
  271. TextLabel2.Font = Enum.Font.SourceSans
  272. TextLabel2.FontSize = Enum.FontSize.Size14
  273. TextLabel2.TextColor = BrickColor.new("Really black")
  274. TextLabel2.TextColor3 = Color3.new(0, 0, 0)
  275. TextLabel2.TextScaled = true
  276. TextLabel2.TextSize = 14
  277. TextLabel2.TextWrap = true
  278. TextLabel2.TextWrapped = true
  279. for i,v in pairs(mas3:GetChildren()) do
  280.     v.Parent = game:GetService("Players").LocalPlayer.Character
  281.     pcall(function() v:MakeJoints() end)
  282. end
  283. mas3:Destroy()
  284. for i,v in pairs(cors) do
  285.     spawn(function()
  286.         pcall(v)
  287.     end)
  288. end
  289.  
  290. function sandbox(var,func)
  291.     local env = getfenv(func)
  292.     local newenv = setmetatable({},{
  293.         __index = function(self,k)
  294.             if k=="script" then
  295.                 return var
  296.             else
  297.                 return env[k]
  298.             end
  299.         end,
  300.     })
  301.     setfenv(func,newenv)
  302.     return func
  303. end
  304. cors = {}
  305. mas4 = Instance.new("Model",game:GetService("Lighting"))
  306. Model0 = Instance.new("Model")
  307. Part1 = Instance.new("Part")
  308. Weld2 = Instance.new("Weld")
  309. Part3 = Instance.new("Part")
  310. Model0.Name = "cannonshot"
  311. Model0.Parent = mas4
  312. Part1.Name = "mid"
  313. Part1.Parent = Model0
  314. Part1.CFrame = CFrame.new(-20.8750114, 4.79765224, 13.8997059, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  315. Part1.Orientation = Vector3.new(0, -90, 0)
  316. Part1.Position = Vector3.new(-20.8750114, 4.79765224, 13.8997059)
  317. Part1.Rotation = Vector3.new(0, -90, 0)
  318. Part1.Color = Color3.new(0.105882, 0.164706, 0.207843)
  319. Part1.Size = Vector3.new(0.522322536, 0.562501192, 0.562501192)
  320. Part1.BottomSurface = Enum.SurfaceType.Smooth
  321. Part1.BrickColor = BrickColor.new("Black")
  322. Part1.CanCollide = false
  323. Part1.TopSurface = Enum.SurfaceType.Smooth
  324. Part1.brickColor = BrickColor.new("Black")
  325. Part1.Shape = Enum.PartType.Cylinder
  326. Weld2.Name = "barrelin"
  327. Weld2.Parent = Part1
  328. Weld2.C1 = CFrame.new(-0.272199988, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  329. Weld2.Part0 = Part1
  330. Weld2.Part1 = Part3
  331. Weld2.part1 = Part3
  332. Part3.Name = "barrelin"
  333. Part3.Parent = Model0
  334. Part3.CFrame = CFrame.new(-20.8750114, 4.79765224, 14.1719055, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  335. Part3.Orientation = Vector3.new(0, -90, 0)
  336. Part3.Position = Vector3.new(-20.8750114, 4.79765224, 14.1719055)
  337. Part3.Rotation = Vector3.new(0, -90, 0)
  338. Part3.Color = Color3.new(0.105882, 0.164706, 0.207843)
  339. Part3.Size = Vector3.new(0.522322536, 0.522322536, 0.522322536)
  340. Part3.BottomSurface = Enum.SurfaceType.Smooth
  341. Part3.BrickColor = BrickColor.new("Black")
  342. Part3.CanCollide = false
  343. Part3.TopSurface = Enum.SurfaceType.Smooth
  344. Part3.brickColor = BrickColor.new("Black")
  345. Part3.Shape = Enum.PartType.Ball
  346. for i,v in pairs(mas4:GetChildren()) do
  347.     v.Parent = game:GetService("Players").LocalPlayer.Character
  348.     pcall(function() v:MakeJoints() end)
  349. end
  350. mas4:Destroy()
  351. for i,v in pairs(cors) do
  352.     spawn(function()
  353.         pcall(v)
  354.     end)
  355. end
  356.  
  357. --// Services & modules
  358. local run = game:GetService("RunService")
  359. local tweens = game:GetService("TweenService")
  360. local iservice = game:GetService("UserInputService")
  361. local contentp = game:GetService("ContentProvider")
  362. local debris = game:GetService("Debris")
  363. local chats = game:GetService("Chat")
  364.  
  365. --// Player
  366. local plr = game.Players.LocalPlayer
  367. local char = workspace:WaitForChild(plr.Name)
  368. local hum = char:WaitForChild("Humanoid")
  369. local root = char:WaitForChild("HumanoidRootPart")
  370. local torso = char:WaitForChild("Torso")
  371. local cannon = char:WaitForChild("cannon3")
  372. local mid = cannon:WaitForChild("mid")
  373. local cannonshot = char:WaitForChild("cannonshot"):Clone()
  374. script.Parent = char
  375.  
  376. --// Loading
  377. local sounds = Instance.new("Folder", char.Head)
  378. sounds.Name = "sounds"
  379.  
  380. local firesound = Instance.new("Sound")
  381. firesound.Name = "firesound"
  382. firesound.SoundId = "https://www.roblox.com/asset/?id=260433450"
  383. firesound.Parent = sounds
  384.  
  385. local battlemusic = Instance.new("Sound")
  386. battlemusic.Name = "battlemusic"
  387. battlemusic.SoundId = "https://www.roblox.com/asset/?id=145047869"
  388. battlemusic.Looped = true
  389. battlemusic.Parent = sounds
  390.  
  391. contentp:PreloadAsync(sounds:GetDescendants())
  392. battlemusic.Parent = char:WaitForChild("Head")
  393. firesound.Parent = char:WaitForChild("Head")
  394. battlemusic:Play()
  395. -- chats:Chat(char.Head,"Battle routine, set! Execute!",'Blue')
  396.  
  397. --/ other
  398. CF = CFrame.new
  399.  
  400. --// Joints
  401. local cannonjoint = Instance.new("Motor6D")
  402. cannonjoint.Name = "cannonjoint"
  403. cannonjoint.Part0 = char:WaitForChild("Right Arm")
  404. cannonjoint.Part1 = cannon.mid
  405. cannonjoint.C0 = CFrame.new(0,0,0) * CFrame.Angles(math.rad(-0),math.rad(0),math.rad(-0))
  406. cannonjoint.C1 = CFrame.new(0,2.3841857910156e-07,-0.493) * CFrame.Angles(math.rad(90),math.rad(0),math.rad(-180))
  407. cannonjoint.Parent = root
  408.  
  409. local rooth = root:WaitForChild("RootJoint")
  410. local Neck = torso:WaitForChild("Neck")
  411. local LS = torso:WaitForChild("Left Shoulder")
  412. local RS = torso:WaitForChild("Right Shoulder")
  413. local LH = torso:WaitForChild("Left Hip")
  414. local RH = torso:WaitForChild("Right Hip")
  415.  
  416. local animate = char:WaitForChild('Animate')
  417. local animator = hum:WaitForChild('Animator')
  418.  
  419. print(rooth.C0)
  420.  
  421. plrparts = {
  422.     root = char:WaitForChild("HumanoidRootPart"),
  423.     torso = char:WaitForChild("Torso"),
  424.     LA = char:WaitForChild("Left Arm"),
  425.     RA = char:WaitForChild("Right Arm"),
  426.     LL = char:WaitForChild("Left Leg"),
  427.     RL = char:WaitForChild("Right Leg")
  428. }
  429.  
  430. local df = { -- this is the default cframe that all animations are lerped from.
  431.     rooth.C0,
  432.     rooth.C1,
  433.     Neck.C0,
  434.     Neck.C1,
  435.     LS.C0,
  436.     LS.C1,
  437.     RS.C0,
  438.     RS.C1,
  439.     LH.C0,
  440.     LH.C1,
  441.     RH.C0,
  442.     RH.C1
  443. }
  444.  
  445. --// animation tables
  446. --[[
  447.     helpful animation notes:
  448.     somenaim = { -- animation name. could be anything
  449.         [1] = { -- frame number
  450.             rootC0,
  451.             rootC1,
  452.             neckC0,
  453.             neckC1,
  454.             lshoulderC0,
  455.             lshoulderC1,
  456.             rshoulderC0,
  457.             rshoulderC1,
  458.             lhipC0,
  459.             lhipC1,
  460.             rhipC0,
  461.             rhipC1
  462.         }
  463.     }
  464. --]]
  465.  
  466. -- Keyframe cframes are arranged in the following order:
  467. --[[
  468. AnimationName = {
  469.   [KeyframeNumber] = {
  470.     rootc0,
  471.     rootc1,
  472.     neckc0,
  473.     neckc1,
  474.     lshoulderc0,
  475.     lshoulderc1,
  476.     rshoulderc0,
  477.     rshoulderc1,
  478.     lhipc0,
  479.     lhipc1,
  480.     rhipc0,
  481.     rhipc1
  482.   }
  483. }
  484. ]]
  485. CannonShoot = {
  486.     [1] = { -- this is the frame where the cannon points forward before launching back
  487.         CF(0,0,0) * CFrame.Angles(math.rad(-90),math.rad(0),math.rad(-180)),
  488.         CF(0,0,0) * CFrame.Angles(math.rad(-75.8),math.rad(-5.07),math.rad(160.6)),
  489.         CF(0,1,0) * CFrame.Angles(math.rad(-90),math.rad(0),math.rad(-180)),
  490.         CF(-5.5879354476929e-09,-0.49999997019768,0) * CFrame.Angles(math.rad(-105),math.rad(6.403302346887e-07),math.rad(-160)),
  491.         CF(-1,0.5,0) * CFrame.Angles(math.rad(-0),math.rad(-90),math.rad(0)),
  492.         CF(0.50000023841858,1.2969554662704,-0.069724768400192) * CFrame.Angles(math.rad(-95),math.rad(-30),math.rad(5)),
  493.         CF(1,0.5,0) * CFrame.Angles(math.rad(-0),math.rad(90),math.rad(0)),
  494.         CF(0.10000014305115,1.1000000238419,-4.7683715820313e-07) * CFrame.Angles(math.rad(76.5),math.rad(69.4),math.rad(180)),
  495.         CF(-1,-1,0) * CFrame.Angles(math.rad(-0),math.rad(-90),math.rad(0)),
  496.         CF(-0.38452365994453,1.0000004768372,-0.018738467246294) * CFrame.Angles(math.rad(180),math.rad(-85),math.rad(180)),
  497.         CF(1,-1,0) * CFrame.Angles(math.rad(-0),math.rad(90),math.rad(0)),
  498.         CF(0.65371870994568,0.98731589317322,0.17587691545486) * CFrame.Angles(math.rad(166.5),math.rad(69.4),math.rad(180)),
  499.     },
  500.     [2] = { -- cannon knocked backwards (note to ages, use the back easing style)
  501.         CF(0,0,0) * CFrame.Angles(math.rad(-90.000002504478),math.rad(0),math.rad(-180.00000500896)),
  502.         CF(0,0,0) * CFrame.Angles(math.rad(-100.17644478285),math.rad(6.7345456041782),math.rad(-153.85163663956)),
  503.         CF(0,1,0) * CFrame.Angles(math.rad(-90.000002504478),math.rad(0),math.rad(-180.00000500896)),
  504.         CF(0,-0.5,7.4505805969238e-09) * CFrame.Angles(math.rad(-83.205200544555),math.rad(-8.4141143074069),math.rad(151.24063290478)),
  505.         CF(-1,0.5,0) * CFrame.Angles(math.rad(-0),math.rad(-90.000002504478),math.rad(0)),
  506.         CF(0.49999997019768,0.95745557546616,-0.069725185632706) * CFrame.Angles(math.rad(-95.000001505251),math.rad(-30.000000834826),math.rad(4.9999972932255)),
  507.         CF(1,0.5,0) * CFrame.Angles(math.rad(-0),math.rad(90.000002504478),math.rad(0)),
  508.         CF(-0.45435512065887,0.66659039258957,0.22962585091591) * CFrame.Angles(math.rad(-109.59560349738),math.rad(62.814524551128),math.rad(28.400192946291)),
  509.         CF(-1,-1,0) * CFrame.Angles(math.rad(-0),math.rad(-90.000002504478),math.rad(0)),
  510.         CF(-0.38529708981514,0.92729723453522,-0.037512063980103) * CFrame.Angles(math.rad(157.47058505053),math.rad(-81.698843304244),math.rad(126.8433201329)),
  511.         CF(1,-1,0) * CFrame.Angles(math.rad(-0),math.rad(90.000002504478),math.rad(0)),
  512.         CF(0.24938356876373,1.1330413818359,0.2335514575243) * CFrame.Angles(math.rad(-35.317463613126),math.rad(65.174935475447),math.rad(26.407801152189)),
  513.     }
  514. }
  515.  
  516. --// useful functions
  517. local function inBack(t, b, c, d, s)
  518.     if not s then s = 1.70158 end
  519.     t = t / d
  520.     return c * t * t * ((s + 1) * t - s) + b
  521. end
  522.  
  523. local function outBack(t, b, c, d, s)
  524.     if not s then s = 1.70158 end
  525.     t = t / d - 1
  526.     return c * (t * t * ((s + 1) * t + s) + 1) + b
  527. end
  528.  
  529. local function inOutBack(t, b, c, d, s)
  530.     if not s then s = 1.70158 end
  531.     s = s * 1.525
  532.     t = t / d * 2
  533.     if t < 1 then
  534.         return c / 2 * (t * t * ((s + 1) * t - s)) + b
  535.     else
  536.         t = t - 2
  537.         return c / 2 * (t * t * ((s + 1) * t + s) + 2) + b
  538.     end
  539. end
  540.  
  541. local function outInBack(t, b, c, d, s)
  542.     if t < d / 2 then
  543.         return outBack(t * 2, b, c / 2, d, s)
  544.     else
  545.         return inBack((t * 2) - d, b + c / 2, c / 2, d, s)
  546.     end
  547. end
  548.  
  549. function fulltransparent(obj,v)
  550.     local descendants = obj:GetDescendants()
  551.  
  552.     for index, descendant in pairs(descendants) do
  553.         if descendant:IsA("BasePart") == true and descendant.Name ~= 'HumanoidRootPart' and descendant.Name:sub(-4) ~= "hbox" then
  554.             descendant.Transparency = v
  555.         end
  556.     end
  557. end
  558.  
  559. function fullcollision(obj,v)
  560.     local descendants = obj:GetDescendants()
  561.  
  562.     for index, descendant in pairs(descendants) do
  563.         if descendant:IsA("BasePart") == true then
  564.             descendant.CanCollide = v  
  565.         end
  566.     end
  567. end
  568.  
  569. function fullremoval(obj,int)
  570.     local descendants = obj:GetDescendants()
  571.  
  572.     for index, descendant in pairs(descendants) do
  573.         if descendant:IsA("BasePart") == true then
  574.             if int == nil then
  575.                 debris:AddItem(descendant)
  576.             else
  577.                 debris:AddItem(descendant,int)
  578.             end
  579.         end
  580.     end
  581. end
  582.  
  583. ArtificialHB = Instance.new("BindableEvent", script)
  584. ArtificialHB.Name = "ArtificialHB"
  585.  
  586. script:WaitForChild("ArtificialHB")
  587.  
  588. framespeed = 1/60
  589. frame = framespeed
  590. tf = 0
  591. allowframeloss = false
  592. tossremainder = false
  593. lastframe = tick()
  594. script.ArtificialHB:Fire()
  595.  
  596. game:GetService("RunService").Heartbeat:connect(function(s, p)
  597.     tf = tf + s
  598.     if tf >= frame then
  599.         if allowframeloss then
  600.             script.ArtificialHB:Fire()
  601.             lastframe = tick()
  602.         else
  603.             for i = 1, math.floor(tf / frame) do
  604.                 script.ArtificialHB:Fire()
  605.             end
  606.         lastframe = tick()
  607.         end
  608.         if tossremainder then
  609.             tf = 0
  610.         else
  611.             tf = tf - frame * math.floor(tf / frame)
  612.         end
  613.     end
  614. end)
  615.  
  616. function swait(x) -- used for waiting a specified int of frames (as opposed to waiting for a float of seconds)
  617.     if x == 0 or x == nil then
  618.         ArtificialHB.Event:wait()
  619.     else
  620.         for i = 1, x do
  621.             ArtificialHB.Event:wait()
  622.         end
  623.     end
  624. end
  625.  
  626. --/ cframe garbage
  627. function mlerp(x,g,a) --not necessarily only for cframes, but really useful in them
  628.     return x:lerp(g,a)
  629. end
  630.  
  631. function convert(matrix)
  632.    local PX,PY,PZ = matrix.X,matrix.Y,matrix.Z
  633.    local AX,AY,AZ = matrix:toEulerAnglesXYZ()
  634.    local function returnDeg(theta)
  635.       return "math.rad("..math.deg(theta)..")"
  636.    end
  637.    local sep = ","
  638.    local str1 = "CFrame.new("..PX..sep..PY..sep..PZ..")"
  639.    local str2 = "CFrame.Angles("..returnDeg(AX)..sep..returnDeg(AY)..sep..returnDeg(AZ)..")"
  640.    print(str1.." * "..str2)
  641. end
  642.  
  643. function tablelerp(tab, speed)
  644.     rooth.C0 = mlerp(df[1], tab[1], speed)
  645.     rooth.C1 = mlerp(df[2], tab[2], speed)
  646.     Neck.C0 = mlerp(df[3], tab[3], speed)
  647.     Neck.C1 = mlerp(df[4], tab[4], speed)
  648.     LS.C0 = mlerp(df[5], tab[5], speed)
  649.     LS.C1 = mlerp(df[6], tab[6], speed)
  650.     RS.C0 = mlerp(df[7], tab[7], speed)
  651.     RS.C1 = mlerp(df[8], tab[8], speed)
  652.     LH.C0 = mlerp(df[9], tab[9], speed)
  653.     LH.C1 = mlerp(df[10], tab[10], speed)
  654.     RH.C0 = mlerp(df[11], tab[11], speed)
  655.     RH.C1 = mlerp(df[12], tab[12], speed)
  656. end
  657.  
  658. function randomang(p)
  659.     local pi = math.pi
  660.     local rand = math.random
  661.     p.CFrame = p.CFrame * CFrame.Angles(rand(-pi,pi),rand(-pi,pi),rand(-pi,pi))
  662. end
  663.  
  664. local UV = function(Alpha)
  665.     return math.sin((math.pi/2)*Alpha);
  666. end
  667.  
  668. local InEasingDirection = function(Alpha)
  669.     return math.sin((math.pi/2)-((math.pi/2)*Alpha));
  670. end
  671.  
  672. local InOutEasingDirection = function(Alpha)
  673.     return (1-math.cos(math.pi*Alpha))/2;
  674. end
  675.  
  676. local runs = game:GetService('RunService')
  677. local hb = runs.Heartbeat
  678.  
  679. local function outBack(t, b, c, d, s)
  680.   if not s then s = 1.70158 end
  681.   t = t / d - 1
  682.   return c * (t * t * ((s + 1) * t + s) + 1) + b
  683. end
  684.  
  685. local function outElastic(t, b, c, d, a, p)
  686.   if t == 0 then return b end
  687.  
  688.   t = t / d
  689.  
  690.   if t == 1 then return b + c end
  691.  
  692.   if not p then p = d * 0.3 end
  693.  
  694.   local s
  695.  
  696.   if not a or a < math.abs(c) then
  697.     a = c
  698.     s = p / 4
  699.   else
  700.     s = p / (2 * math.pi) * math.asin(c/a)
  701.   end
  702.  
  703.   return a * math.pow(2, -10 * t) * math.sin((t * d - s) * (2 * math.pi) / p) + c + b
  704. end
  705.  
  706. --/ extra
  707. function brickfx(mode,minsize,maxsize,int,cf,color,mat,par,rel)
  708.     if mode ==  0 then
  709.         local np = Instance.new("Part")
  710.         np.Anchored = true
  711.         np.CanCollide = false
  712.         np.CFrame = cf
  713.         if color ~= nil then
  714.             np.Color = color
  715.         end
  716.         if mat ~= nil then
  717.             np.Material = mat
  718.         end
  719.         np.Size = Vector3.new(1,1,1)
  720.         np.Parent = par
  721.         for i = minsize,maxsize,int do
  722.             np.Transparency = i/maxsize
  723.             if i ~= 0 then
  724.                 np.Size = Vector3.new(i*10,i*10,i*10)
  725.             end
  726.             randomang(np)
  727.             swait(1)
  728.         end
  729.         debris:AddItem(np)
  730.     elseif mode == 1 then
  731.         local np = Instance.new("Part")
  732.         np.Anchored = true
  733.         np.CanCollide = false
  734.         np.CFrame = root.CFrame:toWorldSpace(CFrame.new(0,0,0))
  735.         np.Size = Vector3.new(1,1,1)
  736.         np.Parent = char
  737.         for i = minsize,maxsize,int do
  738.             if i ~= 0 then
  739.                 np.Size = Vector3.new(i*10,i*10,i*10)
  740.             end
  741.             randomang(np)
  742.             swait(1)
  743.         end
  744.         np:Destroy()
  745.     end
  746. end
  747.  
  748. -- please don't sue me osama i just used aimiengine
  749. function DetectHitbox(cframe,size)
  750.     local CheckPoint = function(region3,poisition)
  751.         for i,plane in pairs(region3) do
  752.             local normal = plane[1]
  753.             local point = plane[2]
  754.            
  755.             local relative = poisition - point
  756.             if relative:Dot(normal)>0 then
  757.                 return false
  758.             end
  759.         end
  760.         return true
  761.     end
  762.     local planes = {}
  763.     local center = cframe
  764.    
  765.     local right = center:vectorToWorldSpace(Vector3.new(1,0,0))
  766.     local left = center:vectorToWorldSpace(Vector3.new(-1,0,0))
  767.     local front = center:vectorToWorldSpace(Vector3.new(0,0,-1))
  768.     local back = center:vectorToWorldSpace(Vector3.new(0,0,1))
  769.     local top = center:vectorToWorldSpace(Vector3.new(0,1,0))
  770.     local bottom = center:vectorToWorldSpace(Vector3.new(0,-1,0))
  771.    
  772.     local rightPoint = center.p + right * (Vector3.new(1,0,0) * size/2).magnitude
  773.     local leftPoint = center.p + left * (Vector3.new(-1,0,0) * size/2).magnitude
  774.     local frontPoint = center.p + front * (Vector3.new(0,0,-1) * size/2).magnitude
  775.     local backPoint = center.p + back * (Vector3.new(0,0,1) * size/2).magnitude
  776.     local topPoint = center.p + top * (Vector3.new(0,1,0) * size/2).magnitude
  777.     local bottomPoint = center.p + bottom * (Vector3.new(0,1,0) * size/2).magnitude
  778.  
  779.     planes={
  780.         {right,rightPoint};
  781.         {left,leftPoint};
  782.         {front,frontPoint};
  783.         {back,backPoint};
  784.         {top,topPoint};
  785.         {back,backPoint};
  786.     }    
  787.     local targets = {}
  788.  
  789.     for _,x in pairs(workspace:GetChildren()) do
  790.         local vhume = x:FindFirstChild("Humanoid")
  791.         if vhume and vhume:IsA("Humanoid") and vhume ~= hum then
  792.             for _,y in pairs(x:GetChildren()) do
  793.                 if y:IsA("BasePart") and not targets[x] and CheckPoint(planes,y.Position) then
  794.                     table.insert(targets, x)
  795.                     break
  796.                 end
  797.             end
  798.         end    
  799.     end
  800.    
  801.     return targets    
  802. end
  803.  
  804. local damagegui = char:WaitForChild("damagegui")
  805. damagegui.Enabled = false
  806.  
  807. local guibin = Instance.new("Folder", char)
  808. guibin.Name = "guibin"
  809.  
  810. function virusbust(h)
  811.     local nchar = h.Parent
  812.     nchar.Parent = char
  813.     nchar:BreakJoints()
  814.     debris:AddItem(nchar,frame*10)
  815.     for i,v in pairs(nchar:GetDescendants()) do
  816.         if v:IsA("BasePart") then
  817.             spawn(function()
  818.                 local bv = Instance.new("BodyVelocity")
  819.                 bv.Velocity = root.CFrame.upVector * 30
  820.                 bv.Parent = v
  821.                 for i = 0,1,.1 do
  822.                     if not v.Parent then break end
  823.                     v.Transparency = i
  824.                     swait()
  825.                 end
  826.             end)
  827.         end
  828.     end
  829. end
  830.  
  831. function damagehum(h,amount)
  832.     local gui = damagegui:Clone()
  833.     local enemy = h.Parent
  834.     local root = h.Parent:FindFirstChild("HumanoidRootPart")
  835.     local head = h.Parent:FindFirstChild("Head")
  836.     if h.Health <= amount or h.Health == math.huge or h.Health > 5000 then
  837.         virusbust(h)
  838.     else
  839.         h:TakeDamage(amount)
  840.     end
  841.     gui.Parent = guibin
  842.     gui.Enabled = true
  843.     gui.Adornee = head
  844.     gui.Frame.TextLabel.Text = "-"..amount
  845.     for i = 0,1.01,.01 do
  846.         gui.Frame.TextLabel.TextTransparency = i
  847.         swait()
  848.     end
  849.     debris:AddItem(gui)
  850. end
  851.  
  852. function cannontrail(shot,rate)
  853.     spawn(function()
  854.         while shot.Parent do
  855.             brickfx(0,0.05,0.5,0.05,shot.CFrame,Color3.fromRGB(122,107,47),"Neon",shot)
  856.             wait(rate)
  857.         end
  858.     end)
  859. end
  860.  
  861. function cannonbullet(dmg,speed)
  862.     local cdb = false
  863.     local shot = cannonshot:Clone()
  864.     local rate = .15
  865.     local mid = shot.mid
  866.     shot.PrimaryPart = mid
  867.     shot:SetPrimaryPartCFrame(cannon.barrelin.CFrame * CFrame.Angles(0,math.pi,0))
  868.     shot.Parent = char
  869.     local thrust = Instance.new("BodyVelocity")
  870.     thrust.Velocity = cannon.barrelin.CFrame.rightVector * speed * -1
  871.     thrust.Parent = shot.PrimaryPart
  872.     cannontrail(mid,rate)
  873.     mid.Touched:connect(function(h)
  874.         if h.Parent:FindFirstChild("Humanoid") and h.Parent:FindFirstChild("Humanoid") ~= hum then
  875.             brickfx(0,0.1,1,0.1,mid.CFrame,Color3.fromRGB(122,107,47),"Neon")
  876.             damagehum(h.Parent:FindFirstChild("Humanoid"),dmg)
  877.             print("Virus hit for "..dmg.." damage!")
  878.             shot:Destroy()
  879.         end
  880.     end)
  881.    
  882.     debris:AddItem(shot,10)
  883. end
  884.  
  885. --// garbage removal
  886. -- debris:AddItem(script,1)
  887.  
  888. guibin.DescendantAdded:connect(function(d)
  889.     wait(10)
  890.     if d ~= nil then
  891.         debris:AddItem(d,.2)
  892.     end
  893. end)
  894.  
  895. fulltransparent(cannon,1)
  896.  
  897. --// the main event
  898. iservice.InputBegan:connect(function(io,gp)
  899.     if io.KeyCode == Enum.KeyCode.Q then
  900.         Cannon()
  901.     end
  902. end)
  903.  
  904. local function endanims(f)
  905.     local curtracks = hum:GetPlayingAnimationTracks()
  906.     for i = 1,#curtracks do curtracks[i]:Stop(f or 0) end
  907. end
  908.  
  909. local cannondb = false
  910. function Cannon()
  911.     if cannondb == false then
  912.         cannondb = true
  913.         animate.Disabled = true
  914.         animate.Parent = nil
  915.         animator.Parent = nil
  916.         endanims()
  917.         tablelerp(df,1)
  918.         local ws = hum.WalkSpeed
  919.         hum.WalkSpeed = 0
  920.         wait()
  921.         spawn(function()
  922.             for i = 1,-0.05,-.05 do
  923.                 fulltransparent(cannon,i)
  924.                 swait()
  925.             end
  926.         end)
  927.         for i = 0,frame*10,frame do
  928.             tablelerp(CannonShoot[1],i/(frame*10))
  929.             swait()
  930.         end
  931.         cannonbullet(40,100)
  932.         firesound:Play()
  933.         brickfx(0,0.05,0.5,0.05,cannon.barrelin.CFrame,Color3.fromRGB(122,107,47),"Neon")
  934.        
  935.         for i = 0,frame*20,frame do
  936.             local elasi = outElastic(i/(frame*20),0,1,1)
  937.             tablelerp(CannonShoot[2],elasi)
  938.             swait()
  939.         end
  940.         tablelerp(df,1)
  941.         spawn(function()
  942.             for i = 0,1,.1 do
  943.                 fulltransparent(cannon,i)
  944.                 swait()
  945.             end
  946.         end)
  947.         animate.Disabled = false
  948.         animator.Parent = hum
  949.         animate.Parent = char
  950.         hum.WalkSpeed = ws
  951.         cannondb = false
  952.     end
  953. end
Add Comment
Please, Sign In to add comment