Sergeant_SethZP

Staffur

Sep 16th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.08 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local Lighting = game:GetService("Lighting")
  3. local Debris = game:GetService("Debris")
  4. local Player = Players.LocalPlayer
  5. local Mouse = Player:GetMouse()
  6. local Char = Player.Character
  7. local RArm = Char["Right Arm"]
  8. local MainColor = "Crimson"
  9. local Model = Instance.new("Model",Char)
  10. local Activated = false
  11. local LightningEffectOn = false
  12. Model.Name = "MasterBolt"
  13. for i,v in pairs(Char:GetChildren()) do
  14. if v:IsA("Shirt") or v:IsA("Pants") or v:IsA("CharacterMesh") or v:IsA("BodyColors") then
  15. v:Destroy()
  16. elseif v:IsA("BasePart") then
  17. v.BrickColor = BrickColor.new("Crimson")
  18. end
  19. end
  20. local BG = Instance.new("BodyGyro",Char.Torso)
  21. BG.maxTorque = Vector3.new(0,0,0)
  22. local BG2 = Instance.new("BodyGyro",Char.Head)
  23. BG2.maxTorque = Vector3.new(0,0,0)
  24. local RW = Instance.new("Weld",Char.Torso)
  25. RW.Part0 = Char.Torso
  26. local Bolt = Instance.new("Part",Model)
  27. Bolt.BrickColor = BrickColor.new("Crimson")
  28. Bolt.CanCollide = false
  29. Bolt.FormFactor = "Custom"
  30. Bolt.TopSurface = "Smooth"
  31. Instance.new("CylinderMesh",Bolt)
  32. Bolt.BottomSurface = "Smooth"
  33. Bolt.Size = Vector3.new(0.5,2,0.5)
  34. Bolt:BreakJoints()
  35. local BW = Instance.new("Weld",Bolt)
  36. BW.Part0 = RArm
  37. BW.Part1 = Bolt
  38. BW.C1 = CFrame.new(0.2,0,1) * CFrame.Angles(math.rad(90),0,0)
  39. local Tip = Instance.new("Part",Model)
  40. Tip.BrickColor = BrickColor.new("Crimson")
  41. Tip.CanCollide = false
  42. Tip.FormFactor = "Custom"
  43. Tip.TopSurface = "Smooth"
  44. Tip.BottomSurface = "Smooth"
  45. local Mesh = Instance.new("SpecialMesh",Tip)
  46. Mesh.MeshId = "http://www.roblox.com/asset/?id=1033714"
  47. Mesh.Scale = Vector3.new(0.25,0.5,0.25)
  48. Tip.Size = Vector3.new(0.48,0.5,0.48)
  49. Tip:BreakJoints()
  50. local TW = Instance.new("Weld",Tip)
  51. TW.Part0 = Bolt
  52. TW.Part1 = Tip
  53. TW.C1 = CFrame.new(0,-1.175,0)
  54. local Tip2 = Instance.new("Part",Model)
  55. Tip2.BrickColor = BrickColor.new("Crimson")
  56. Tip2.CanCollide = false
  57. Tip2.FormFactor = "Custom"
  58. Tip2.TopSurface = "Smooth"
  59. Tip2.BottomSurface = "Smooth"
  60. local Mesh2 = Instance.new("SpecialMesh",Tip2)
  61. Mesh2.MeshId = "http://www.roblox.com/asset/?id=1033714"
  62. Mesh2.Scale = Vector3.new(0.25,0.5,0.25)
  63. Tip2.Size = Vector3.new(0.48,0.5,0.48)
  64. Tip2:BreakJoints()
  65. local TW2 = Instance.new("Weld",Tip2)
  66. TW2.Part0 = Bolt
  67. TW2.Part1 = Tip2
  68. TW2.C1 = CFrame.new(0,-1.175,0) * CFrame.Angles(0,0,math.rad(180))
  69. function ComputePos(pos1, pos2)
  70. return CFrame.new(pos1, Vector3.new(pos2.x, pos1.y, pos2.z))
  71. end
  72. function LightningEffect(Pos,Color,Size,Time)
  73. local Mod = Instance.new("Model",Char)
  74. Mod.Name = "Lightning"
  75. for i = 1,Size do
  76. local LastPos = Pos
  77. for i2 = 1,math.random(Size-1,Size+1) do
  78. local Targ = LastPos * CFrame.new(math.random(-Size,Size),math.random(-Size,Size),math.random(-Size,Size))
  79. local P = Instance.new("Part",Mod)
  80. P.BrickColor = Color
  81. P.FormFactor = "Custom"
  82. Instance.new("CylinderMesh",P)
  83. P.Size = Vector3.new(0,(Targ.p-LastPos.p).Magnitude,0)
  84. P.CFrame = CFrame.new(LastPos.p, Targ.p) * CFrame.Angles(math.pi/2,0,0) * CFrame.new(0,-(Targ.p-LastPos.p).Magnitude/2,0)
  85. P.Anchored = true
  86. P.CanCollide = false
  87. P.TopSurface = "Smooth"
  88. P.BottomSurface = "Smooth"
  89. P.Name = "LightningPart"
  90. P:BreakJoints()
  91. local P2 = Instance.new("Part",Mod)
  92. P2.BrickColor = Color
  93. P2.FormFactor = "Custom"
  94. Instance.new("CylinderMesh",P2)
  95. P2.Size = P.Size + Vector3.new(0.1,0.1,0.1)
  96. P2.CFrame = P.CFrame
  97. P2.Transparency = 0.7
  98. P2.Anchored = true
  99. P2.CanCollide = false
  100. P2.TopSurface = "Smooth"
  101. P2.BottomSurface = "Smooth"
  102. P2.Name = "LightningPart"
  103. P2:BreakJoints()
  104. LastPos = Targ
  105. end
  106. end
  107. Debris:AddItem(Mod,Time or 0.1)
  108. end
  109. function Break(Obj,Base,Dis)
  110. for i,v in pairs(Obj:GetChildren()) do
  111. if v:IsA("BasePart") and (v.Position-Base.Position).Magnitude <= Dis then
  112. if v.Name ~= "Base" and v.Parent ~= Char and v.Parent.Parent ~= Char and v ~= Base then
  113. v.BrickColor = BrickColor.new("Black")
  114. v.Anchored = false
  115. v:BreakJoints()
  116. EXP = Instance.new("Explosion",workspace)
  117. EXP.Position = v.Position
  118. EXP.BlastRadius = 1
  119. end
  120. end
  121. Break(v,Base,Dis)
  122. end
  123. end
  124. function ExplosionEffect(Pos)
  125. coroutine.resume(coroutine.create(function()
  126. local Base = Instance.new("Part",Char)
  127. Base.Anchored = true
  128. Base.Shape = "Ball"
  129. Base.FormFactor = "Custom"
  130. Base.Size = Vector3.new(10,10,10)
  131. Base.CFrame = Pos
  132. Base.Transparency = 0.25
  133. Base.BrickColor = BrickColor.new(MainColor)
  134. Base.TopSurface = "Smooth"
  135. Base.BottomSurface = "Smooth"
  136. Base.Name = "Explosion"
  137. for i = 1,100,2 do
  138. Base.Size = Base.Size + Vector3.new(1,1,1)
  139. Base.CFrame = Pos
  140. Base.Transparency = i*0.01
  141. Break(Workspace,Base,Base.Size.Y/2)
  142. wait(0.0001)
  143. end
  144. Base:Destroy()
  145. end))
  146. end
  147. function LightningBeam(Pos1,Pos,Color,Size,Time)
  148. local Mod = Instance.new("Model",Char)
  149. Mod.Name = "Lightning"
  150. local LastPos = Pos1
  151. local End = math.floor((Pos.p-Pos1.p).Magnitude/3)
  152. local Targ = nil
  153. for i2 = 1,End do
  154. if i2 == End then
  155. Targ = Pos
  156. else
  157. for i = 1,100 do
  158. Targ = LastPos * CFrame.new(math.random(-6,6),math.random(-6,6),math.random(-6,6))
  159. if (Targ.p-Pos.p).Magnitude < (LastPos.p-Pos.p).Magnitude and (math.abs(Targ.Y-Pos.Y) - math.abs(LastPos.Y-Pos.Y)) < math.abs(Pos1.Y-Pos.Y) then
  160. break
  161. end
  162. end
  163. end
  164. local P = Instance.new("Part",Mod)
  165. P.BrickColor = Color
  166. P.FormFactor = "Custom"
  167. Instance.new("CylinderMesh",P)
  168. P.Size = Vector3.new(Size,(Targ.p-LastPos.p).Magnitude,Size)
  169. P.CFrame = CFrame.new(LastPos.p, Targ.p) * CFrame.Angles(math.pi/2,0,0) * CFrame.new(0,-(Targ.p-LastPos.p).Magnitude/2,0)
  170. P.Anchored = true
  171. P.CanCollide = false
  172. P.TopSurface = "Smooth"
  173. P.BottomSurface = "Smooth"
  174. P.Name = "Main"
  175. P:BreakJoints()
  176. local P2 = Instance.new("Part",Mod)
  177. P2.BrickColor = Color
  178. P2.FormFactor = "Custom"
  179. Instance.new("CylinderMesh",P2)
  180. P2.Size = P.Size + Vector3.new(Size/4,Size/4,Size/4)
  181. P2.CFrame = P.CFrame
  182. P2.Transparency = 0.7
  183. P2.Anchored = true
  184. P2.CanCollide = false
  185. P2.TopSurface = "Smooth"
  186. P2.BottomSurface = "Smooth"
  187. P2.Name = "LightningPart"
  188. P2:BreakJoints()
  189. LastPos = Targ
  190. end
  191. coroutine.resume(coroutine.create(function()
  192. for i = 0,1,0.1 do
  193. for i2,v in pairs(Mod:GetChildren()) do
  194. if v:IsA("BasePart") then
  195. if v.Name == "Main" then
  196. v.Transparency = i
  197. else
  198. v.Transparency = Vector3.new(0,0.7,0):lerp(Vector3.new(0,1,0),i).Y
  199. end
  200. end
  201. end
  202. wait(i*0.5)
  203. end
  204. Mod:Destroy()
  205. end))
  206. end
  207. TweenWeld = function(c,c1,step)
  208. local c0 = c.C1
  209. if c0 == c1 then
  210. step = 90
  211. end
  212. for i = -90,90,step do
  213. local r = ((math.sin(math.rad(i))+1)/2)
  214. local cf = matrixInterpolate(c0, c1, r)
  215. c.C1 = cf
  216. wait(0.000001)
  217. end
  218. end
  219. function lerp(a, b, t)
  220. return a + (b - a)*t
  221. end
  222. function slerp(a, b, t)
  223. local dot = a:Dot(b)
  224. if dot > 0.99999 or dot < -0.99999 then
  225. return t <= 0.5 and a or b
  226. else
  227. local r = math.acos(dot)
  228. return (a*math.sin((1 - t)*r) + b*math.sin(t*r)) / math.sin(r)
  229. end
  230. end
  231. function matrixInterpolate(a, b, t)
  232. local ax, ay, az, a00, a01, a02, a10, a11, a12, a20, a21, a22 = a:components()
  233. local bx, by, bz, b00, b01, b02, b10, b11, b12, b20, b21, b22 = b:components()
  234. local v0 = lerp(Vector3.new(ax , ay , az ), Vector3.new(bx , by , bz ), t) -- Position
  235. local v1 = slerp(Vector3.new(a00, a01, a02), Vector3.new(b00, b01, b02), t) -- Vector right
  236. local v2 = slerp(Vector3.new(a10, a11, a12), Vector3.new(b10, b11, b12), t) -- Vector up
  237. local v3 = slerp(Vector3.new(a20, a21, a22), Vector3.new(b20, b21, b22), t) -- Vector back
  238. return CFrame.new(
  239. v0.x, v0.y, v0.z,
  240. v1.x, v1.y, v1.z,
  241. v2.x, v2.y, v2.z,
  242. v3.x, v3.y, v3.z)
  243. end
  244. function KeyDown(Key)
  245. if Key:lower() == "q" and not DB then
  246. DB = true
  247. if Activated == false then
  248. RW.Part1 = RArm
  249. RW.C1 = CFrame.new(-1.5,0,0)
  250. TweenWeld(RW,CFrame.new(-1,1.5,0.5) * CFrame.Angles(math.rad(-150),0,math.rad(10)),6)
  251. for i = Bolt.Size.Y,5,0.1 do
  252. Bolt.Size = Vector3.new(0.5,i,0.5)
  253. BW.Part0 = RArm
  254. BW.Part1 = Bolt
  255. BW.C1 = CFrame.new(0.1,0,1) * CFrame.Angles(math.rad(90),0,0)
  256. BW.Parent = Bolt
  257. TW.Part0 = Bolt
  258. TW.Part1 = Tip
  259. Mesh.Scale = Mesh.Scale + Vector3.new(0,0.005,0)
  260. TW.C1 = CFrame.new(0,-(i/2+0.175+(Mesh.Scale.Y-0.5)/2.75),0)
  261. TW.Parent = Tip
  262. TW2.Part0 = Bolt
  263. TW2.Part1 = Tip2
  264. Mesh2.Scale = Mesh2.Scale + Vector3.new(0,0.005,0)
  265. TW2.C1 = CFrame.new(0,-(i/2+0.175+(Mesh2.Scale.Y-0.5)/2.75),0) * CFrame.Angles(0,0,math.rad(180))
  266. TW2.Parent = Tip2
  267. wait(0.000001)
  268. BW.Part0 = RArm
  269. BW.Part1 = Bolt
  270. BW.C1 = CFrame.new(0.1,0,1) * CFrame.Angles(math.rad(90),0,0)
  271. BW.Parent = Bolt
  272. TW.Part0 = Bolt
  273. TW.Part1 = Tip
  274. TW.C1 = CFrame.new(0,-(i/2+0.175+(Mesh.Scale.Y-0.5)/2.75),0)
  275. TW.Parent = Tip
  276. TW2.Part0 = Bolt
  277. TW2.Part1 = Tip2
  278. TW2.C1 = CFrame.new(0,-(i/2+0.175+(Mesh2.Scale.Y-0.5)/2.75),0) * CFrame.Angles(0,0,math.rad(180))
  279. TW2.Parent = Tip2
  280. local Color = Vector3.new(BrickColor.new("White").r,BrickColor.new("White").g,BrickColor.new("White").b):lerp(Vector3.new(BrickColor.new(MainColor).r,BrickColor.new(MainColor).g,BrickColor.new(MainColor).b),i/5)
  281. Bolt.Color = Color3.new(Color.X,Color.Y,Color.Z)
  282. Tip.Color = Bolt.Color
  283. Tip2.Color = Bolt.Color
  284. end
  285. LightningEffectOn = true
  286. TweenWeld(RW,CFrame.new(-1.2,0.5,0.5) * CFrame.Angles(math.rad(-40),math.rad(10),0),6)
  287. Activated = true
  288. else
  289. TweenWeld(RW,CFrame.new(-1.5,0,0),6)
  290. RW.Part1 = nil
  291. LightningEffectOn = false
  292. for i = Bolt.Size.Y,2,-0.1 do
  293. Bolt.Size = Vector3.new(0.5,i,0.5)
  294. BW.Part0 = RArm
  295. BW.Part1 = Bolt
  296. BW.C1 = CFrame.new(0.1,0,1) * CFrame.Angles(math.rad(90),0,0)
  297. BW.Parent = Bolt
  298. TW.Part0 = Bolt
  299. TW.Part1 = Tip
  300. Mesh.Scale = Mesh.Scale - Vector3.new(0,0.005,0)
  301. TW.C1 = CFrame.new(0,-(i/2+0.175+(Mesh.Scale.Y-0.5)/2.75),0)
  302. TW.Parent = Tip
  303. TW2.Part0 = Bolt
  304. TW2.Part1 = Tip2
  305. Mesh2.Scale = Mesh2.Scale - Vector3.new(0,0.005,0)
  306. TW2.C1 = CFrame.new(0,-(i/2+0.175+(Mesh2.Scale.Y-0.5)/2.75),0) * CFrame.Angles(0,0,math.rad(180))
  307. TW2.Parent = Tip2
  308. wait(0.000001)
  309. BW.Part0 = RArm
  310. BW.Part1 = Bolt
  311. BW.C1 = CFrame.new(0.1,0,1) * CFrame.Angles(math.rad(90),0,0)
  312. BW.Parent = Bolt
  313. TW.Part0 = Bolt
  314. TW.Part1 = Tip
  315. TW.C1 = CFrame.new(0,-(i/2+0.175+(Mesh.Scale.Y-0.5)/2.75),0)
  316. TW.Parent = Tip
  317. TW2.Part0 = Bolt
  318. TW2.Part1 = Tip2
  319. TW2.C1 = CFrame.new(0,-(i/2+0.175+(Mesh2.Scale.Y-0.5)/2.75),0) * CFrame.Angles(0,0,math.rad(180))
  320. TW2.Parent = Tip2
  321. local Color = Vector3.new(BrickColor.new(MainColor).r,BrickColor.new(MainColor).g,BrickColor.new(MainColor).b):lerp(Vector3.new(BrickColor.new("WHite").r,BrickColor.new("White").g,BrickColor.new("White").b),(2/i))
  322. Bolt.Color = Color3.new(Color.X,Color.Y,Color.Z)
  323. Tip.Color = Bolt.Color
  324. Tip2.Color = Bolt.Color
  325. end
  326. TW.Part0 = Bolt
  327. TW.Part1 = Tip
  328. TW.C1 = CFrame.new(0,-1.175,0)
  329. TW2.Part0 = Bolt
  330. TW2.Part1 = Tip2
  331. TW2.C1 = CFrame.new(0,-1.175,0) * CFrame.Angles(0,0,math.rad(180))
  332. Activated = false
  333. end
  334. DB = false
  335. elseif Key:lower() == "e" and Activated and not DB then
  336. DB = true
  337. TweenWeld(RW,CFrame.new(-1,1.5,0.25) * CFrame.Angles(math.rad(-170),0,math.rad(10)),10)
  338. wait(0.1)
  339. TweenWeld(RW,CFrame.new(-1,2,-0.3) * CFrame.Angles(math.rad(-155),0,math.rad(10)),11)
  340. if (Mouse.Hit.p-Tip2.CFrame.p).Magnitude > 300 then
  341. LightningBeam(Tip2.CFrame,(Mouse.Hit-Mouse.Hit.p) * CFrame.new(0,0,-300),BrickColor.new(MainColor),0.5,0.5)
  342. ExplosionEffect((Mouse.Hit-Mouse.Hit.p) * CFrame.new(0,0,-300))
  343. else
  344. LightningBeam(Tip2.CFrame,Mouse.Hit,BrickColor.new(MainColor),0.5,0.5)
  345. ExplosionEffect(Mouse.Hit)
  346. end
  347. LightningEffectOn = false
  348. for i = 0,1,0.15 do
  349. local Color = Vector3.new(BrickColor.new(MainColor).r,BrickColor.new(MainColor).g,BrickColor.new(MainColor).b):lerp(Vector3.new(BrickColor.new("White").r,BrickColor.new("White").g,BrickColor.new("White").b),(i/1))
  350. Bolt.Color = Color3.new(Color.X,Color.Y,Color.Z)
  351. Tip.Color = Bolt.Color
  352. Tip2.Color = Bolt.Color
  353. wait(0.0001)
  354. end
  355. TweenWeld(RW,CFrame.new(-1.2,0.5,0.5) * CFrame.Angles(math.rad(-40),math.rad(10),0),10)
  356. for i = 0,1,0.15 do
  357. local Color = Vector3.new(BrickColor.new("White").r,BrickColor.new("White").g,BrickColor.new("White").b):lerp(Vector3.new(BrickColor.new(MainColor).r,BrickColor.new(MainColor).g,BrickColor.new(MainColor).b),i/1)
  358. Bolt.Color = Color3.new(Color.X,Color.Y,Color.Z)
  359. Tip.Color = Bolt.Color
  360. Tip2.Color = Bolt.Color
  361. wait(0.0001)
  362. end
  363. LightningEffectOn = true
  364. DB = false
  365. end
  366. end
  367. Mouse.KeyDown:connect(KeyDown)
  368. Mouse.Button1Down:connect(Button1Down)
  369. while true do
  370. if Activated and LightningEffectOn then
  371. LightningEffect(Tip2.CFrame,BrickColor.new(MainColor),math.random(0,2),0.12)
  372. LightningEffect(Tip.CFrame,BrickColor.new(MainColor),math.random(0,2),0.12)
  373. LightningEffect(Bolt.CFrame,BrickColor.new(MainColor),math.random(0,2),0.12)
  374. end
  375. if Activated then
  376. BG.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
  377. BG.cframe = ComputePos(Char.Torso.Position,Mouse.Hit.p)
  378. BG2.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
  379. BG2.cframe = ComputePos(Char.Head.Position,Mouse.Hit.p)
  380. else
  381. BG.maxTorque = Vector3.new(0,0,0)
  382. BG2.maxTorque = Vector3.new(0,0,0)
  383. end
  384. for i,v in pairs(Char:GetChildren()) do
  385. if (v:IsA("Shirt") or v:IsA("Pants") or v:IsA("CharacterMesh") or v:IsA("BodyColors")) then
  386. v:Destroy()
  387. elseif v:IsA("BasePart") and v.Name ~= "Explosion" then
  388. v.BrickColor = BrickColor.new("White")
  389. end
  390. end
  391. wait(math.random(0.05,0.15))
  392. end
Add Comment
Please, Sign In to add comment