Advertisement
dpeanut1

Vape Cube

Dec 25th, 2016
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.56 KB | None | 0 0
  1. me = game.Players.dpeanut1
  2. char = me.Character
  3.  
  4. cube = nil
  5.  
  6. size = 1
  7.  
  8. full = 2
  9.  
  10. upper = 13
  11.  
  12. name = "Vape Cube"
  13.  
  14. parts = {}
  15.  
  16. hold = false
  17.  
  18. deb = true
  19.  
  20. loldist = 10
  21.  
  22. modes = {"bomb", "attack"}
  23.  
  24. where = 1
  25.  
  26. mode = modes[where]
  27.  
  28.  
  29. function getavg(m)
  30.  
  31. local x = {}
  32.  
  33. local y = {}
  34.  
  35. local z = {}
  36.  
  37. for _,v in pairs(m:children()) do
  38.  
  39. if v:IsA("BasePart") then
  40.  
  41. table.insert(x,v.Position.X)
  42.  
  43. table.insert(y,v.Position.Y)
  44.  
  45. table.insert(z,v.Position.Z)
  46.  
  47. end
  48.  
  49. end
  50.  
  51. local x2 = 0
  52.  
  53. local y2 = 0
  54.  
  55. local z2 = 0
  56.  
  57. for _,v in pairs(x) do
  58.  
  59. x2 = x2 + v
  60.  
  61. end
  62.  
  63. for _,v in pairs(y) do
  64.  
  65. y2 = y2 + v
  66.  
  67. end
  68.  
  69. for _,v in pairs(z) do
  70.  
  71. z2 = z2 + v
  72.  
  73. end
  74.  
  75. local finalx = x2 / #x
  76.  
  77. local finaly = y2 / #y
  78.  
  79. local finalz = z2 / #z
  80.  
  81. local vec = Vector3.new(finalx,finaly,finalz)
  82.  
  83. return vec
  84.  
  85. end
  86.  
  87.  
  88. function prop(part, parent, collide, tran, ref, x, y, z, color, anchor, form)
  89.  
  90. part.Parent = parent
  91.  
  92. part.formFactor = form
  93.  
  94. part.CanCollide = collide
  95.  
  96. part.Transparency = tran
  97.  
  98. part.Reflectance = ref
  99.  
  100. part.Size = Vector3.new(x,y,z)
  101.  
  102. part.BrickColor = BrickColor.new(color)
  103.  
  104. part.TopSurface = 0
  105.  
  106. part.BottomSurface = 0
  107.  
  108. part.Anchored = anchor
  109.  
  110. part.Locked = true
  111.  
  112. Instance.new("BlockMesh",part)
  113.  
  114. part:BreakJoints()
  115.  
  116. end
  117.  
  118.  
  119. function getnoobs(pos)
  120.  
  121. local hums = {}
  122.  
  123. for _,v in pairs(workspace:children()) do
  124.  
  125. for _,k in pairs(v:children()) do
  126.  
  127. local to = v:findFirstChild("Torso")
  128.  
  129. if k:IsA("Humanoid") and to ~= nil then
  130.  
  131. if (to.Position - pos).magnitude < loldist then
  132.  
  133. table.insert(hums,k)
  134.  
  135. end
  136.  
  137. end
  138.  
  139. end
  140.  
  141. end
  142.  
  143. return hums
  144.  
  145. end
  146.  
  147.  
  148. function makecube(pos)
  149.  
  150. parts = {}
  151.  
  152. for _,v in pairs(workspace:children()) do
  153.  
  154. if v.Name == name then
  155.  
  156. v:remove()
  157.  
  158. end
  159.  
  160. end
  161.  
  162. local mo = Instance.new("Model",workspace)
  163.  
  164. mo.Name = name
  165.  
  166. cube = mo
  167.  
  168. local x, y, z = -full, -full, -full
  169.  
  170. local center = CFrame.new(pos) * CFrame.new(0,upper,0)
  171.  
  172. repeat
  173.  
  174. local cu = Instance.new("Part")
  175.  
  176. prop(cu,mo,false,0,0,size,size,size,"Really black",true,"Custom")
  177.  
  178. cu.CFrame = center * CFrame.new(x,y,z)
  179.  
  180. table.insert(parts,cu)
  181.  
  182. x = x + size
  183.  
  184. if x > full then
  185.  
  186. x = -full
  187.  
  188. y = y + size
  189.  
  190. end
  191.  
  192. if y > full then
  193.  
  194. y = -full
  195.  
  196. z = z + size
  197.  
  198. end
  199.  
  200. until z > full
  201.  
  202. local lo = full+(size*0.1)
  203.  
  204. for o=1,360, 90 do
  205.  
  206. local p = Instance.new("Part")
  207.  
  208. prop(p,mo,false,0,0.15,size,size,size,"Really black",true,"Custom")
  209.  
  210. p.CFrame = center * CFrame.Angles(0,math.rad(o),0) * CFrame.new(lo,lo,lo)
  211.  
  212. table.insert(parts,p)
  213.  
  214. end
  215.  
  216. for o=1,360, 90 do
  217.  
  218. local p = Instance.new("Part")
  219.  
  220. prop(p,mo,false,0,0.15,size,size,size,"Really black",true,"Custom")
  221.  
  222. p.CFrame = center * CFrame.Angles(0,math.rad(o),0) * CFrame.new(lo,-lo,lo)
  223.  
  224. table.insert(parts,p)
  225.  
  226. end
  227.  
  228. for o=1,360, 90 do
  229.  
  230. local p = Instance.new("Part")
  231.  
  232. prop(p,mo,false,0,0.15,size*1.5,size*1.5,size*1.5,"Really black",true,"Custom")
  233.  
  234. p.CFrame = center * CFrame.Angles(0,math.rad(o),0) * CFrame.new(0,0,lo)
  235.  
  236. table.insert(parts,p)
  237.  
  238. end
  239.  
  240. for o=-full,full,full*2 do
  241.  
  242. local p = Instance.new("Part")
  243.  
  244. prop(p,mo,false,0,0.15,size*1.5,size*1.5,size*1.5,"Really black",true,"Custom")
  245.  
  246. p.CFrame = center * CFrame.Angles(0,0,0) * CFrame.new(0,o,0)
  247.  
  248. table.insert(parts,p)
  249.  
  250. end
  251.  
  252. end
  253.  
  254.  
  255. makecube(me.Character.Torso.Position)
  256.  
  257.  
  258. function move(way)
  259.  
  260. coroutine.resume(coroutine.create(function()
  261.  
  262. for i,v in pairs(parts) do
  263.  
  264. wait()
  265.  
  266. if way == "fr" then
  267.  
  268. v.CFrame = CFrame.new(v.Position) * CFrame.new(0,0,-3)
  269.  
  270. elseif way == "ba" then
  271.  
  272. v.CFrame = CFrame.new(v.Position) * CFrame.new(0,0,3)
  273.  
  274. elseif way == "le" then
  275.  
  276. v.CFrame = CFrame.new(v.Position) * CFrame.new(-3,0,0)
  277.  
  278. elseif way == "ri" then
  279.  
  280. v.CFrame = CFrame.new(v.Position) * CFrame.new(3,0,0)
  281.  
  282. elseif way == "up" then
  283.  
  284. v.CFrame = CFrame.new(v.Position) * CFrame.new(0,3,0)
  285.  
  286. elseif way == "do" then
  287.  
  288. v.CFrame = CFrame.new(v.Position) * CFrame.new(0,-3,0)
  289.  
  290. end
  291.  
  292. end
  293.  
  294. end))
  295.  
  296. end
  297.  
  298.  
  299. if script.Parent.className ~= "HopperBin" then
  300.  
  301. h = Instance.new("HopperBin",me.Backpack)
  302.  
  303. h.Name = "VapeCube"
  304.  
  305. script.Parent = h
  306.  
  307. end
  308.  
  309. bin = script.Parent
  310.  
  311. function sel(mouse)
  312.  
  313. mouse.KeyDown:connect(function(key)
  314.  
  315. key = key:lower()
  316.  
  317. if key == "t" then
  318.  
  319. hold = true
  320.  
  321. while hold do
  322.  
  323. move("fr")
  324.  
  325. wait(0.1)
  326.  
  327. end
  328.  
  329. elseif key == "g" then
  330.  
  331. hold = true
  332.  
  333. while hold do
  334.  
  335. move("ba")
  336.  
  337. wait(0.1)
  338.  
  339. end
  340.  
  341. elseif key == "f" then
  342.  
  343. hold = true
  344.  
  345. while hold do
  346.  
  347. move("le")
  348.  
  349. wait(0.1)
  350.  
  351. end
  352.  
  353. elseif key == "h" then
  354.  
  355. hold = true
  356.  
  357. while hold do
  358.  
  359. move("ri")
  360.  
  361. wait(0.1)
  362.  
  363. end
  364.  
  365. elseif key == "u" then
  366.  
  367. hold = true
  368.  
  369. while hold do
  370.  
  371. move("up")
  372.  
  373. wait(0.1)
  374.  
  375. end
  376.  
  377. elseif key == "j" then
  378.  
  379. hold = true
  380.  
  381. while hold do
  382.  
  383. move("do")
  384.  
  385. wait(0.1)
  386.  
  387. end
  388.  
  389. elseif key == "q" then
  390.  
  391. where = where - 1
  392.  
  393. if where < 1 then
  394.  
  395. where = #modes
  396.  
  397. end
  398.  
  399. mode = modes[where]
  400.  
  401. elseif key == "e" then
  402.  
  403. where = where + 1
  404.  
  405. if where > #modes then
  406.  
  407. where = 1
  408.  
  409. end
  410.  
  411. mode = modes[where]
  412.  
  413. elseif key == string.char(9) then
  414.  
  415. makecube(me.Character.Torso.Position)
  416.  
  417. end
  418.  
  419. end)
  420.  
  421. mouse.KeyUp:connect(function(key)
  422.  
  423. key = key:lower()
  424.  
  425. if key == "t" or key == "g" or key == "f" or key == "h" or key == "u" or key == "j" then
  426.  
  427. hold = false
  428.  
  429. end
  430.  
  431. end)
  432.  
  433. mouse.Button1Down:connect(function()
  434.  
  435. if deb then
  436.  
  437. if mode == "attack" then
  438.  
  439. deb = false
  440.  
  441. local poz = mouse.Hit.p
  442.  
  443. lol = false
  444.  
  445. for _,v in pairs(cube:children()) do
  446.  
  447. local lastpos = v.CFrame
  448.  
  449. v.Anchored = false
  450.  
  451. v.Velocity = Vector3.new(math.random(-40,40),math.random(-40,40),0)
  452.  
  453. coroutine.resume(coroutine.create(function()
  454.  
  455. local b = Instance.new("BodyPosition",v)
  456.  
  457. b.P = 12000
  458.  
  459. b.maxForce = Vector3.new(math.huge,math.huge,math.huge)
  460.  
  461. b.position = poz + Vector3.new(math.random(-10,10)/10,math.random(-10,10)/10,math.random(-10,10)/10)
  462.  
  463. wait(2.2)
  464.  
  465. local cf = CFrame.new(poz,b.position) * CFrame.new(0,0,math.random(120,135)/10).p
  466.  
  467. b.position = cf
  468.  
  469. lol = true
  470.  
  471. wait(1.8)
  472.  
  473. b.position = lastpos.p
  474.  
  475. repeat wait() until (v.Position - b.position).magnitude < 3
  476.  
  477. b:remove()
  478.  
  479. v.Anchored = true
  480.  
  481. for i=1,2 do
  482.  
  483. v.CFrame = lastpos
  484.  
  485. wait()
  486.  
  487. end
  488.  
  489. end))
  490.  
  491. end
  492.  
  493. repeat wait() until lol == true
  494.  
  495. local pwn = Instance.new("Part")
  496.  
  497. prop(pwn,cube,false,1,0,1,1,1,"Black",true,"Brick")
  498.  
  499. pwn.CFrame = CFrame.new(poz)
  500.  
  501. local fi = Instance.new("Fire",pwn)
  502.  
  503. fi.Size = 1
  504.  
  505. fi.Heat = 0
  506.  
  507. fi.Color = Color3.new(1,0.3,0)
  508.  
  509. fi.SecondaryColor = fi.Color
  510.  
  511. for i=1,40,1 do
  512.  
  513. wait()
  514.  
  515. fi.Size = i
  516.  
  517. end
  518.  
  519. local hus = getnoobs(pwn.Position)
  520.  
  521. for _,v in pairs(hus) do
  522.  
  523. coroutine.resume(coroutine.create(function()
  524.  
  525. for i=1, 15 do
  526.  
  527. v.Health = v.Health - 4
  528.  
  529. wait()
  530.  
  531. end
  532.  
  533. end))
  534.  
  535. end
  536.  
  537. for i=40,1,-2 do
  538.  
  539. wait()
  540.  
  541. fi.Size = i
  542.  
  543. end
  544.  
  545. pwn:remove()
  546.  
  547. wait(2.4)
  548.  
  549. deb = true
  550.  
  551. elseif mode == "bomb" then
  552.  
  553. deb = false
  554.  
  555. local avrg = getavg(cube)
  556.  
  557. for _,v in pairs(cube:children()) do
  558.  
  559. local lastpos = v.CFrame
  560.  
  561. v.Anchored = false
  562.  
  563. coroutine.resume(coroutine.create(function()
  564.  
  565. local b = Instance.new("BodyPosition",v)
  566.  
  567. b.P = 15000
  568.  
  569. b.maxForce = Vector3.new(math.huge,math.huge,math.huge)
  570.  
  571. b.position = CFrame.new(v.Position, avrg) * CFrame.new(0,0,7).p
  572.  
  573. wait(4)
  574.  
  575. b.Parent = nil
  576.  
  577. b.position = lastpos.p
  578.  
  579. local hih = CFrame.new(v.Position, avrg)
  580.  
  581. v.Velocity = hih.lookVector * 110
  582.  
  583. wait(1.8)
  584.  
  585. b.Parent = v
  586.  
  587. repeat wait() until (v.Position - lastpos.p).magnitude < 4
  588.  
  589. v.Anchored = true
  590.  
  591. b:remove()
  592.  
  593. v.CFrame = lastpos
  594.  
  595. end))
  596.  
  597. end
  598.  
  599. local pwn = Instance.new("Part")
  600.  
  601. prop(pwn,cube,false,1,0,1,1,1,"Black",true,"Brick")
  602.  
  603. pwn.CFrame = CFrame.new(avrg)
  604.  
  605. local fi = Instance.new("Fire",pwn)
  606.  
  607. fi.Size = 1
  608.  
  609. fi.Heat = 0
  610.  
  611. fi.Color = Color3.new(1,0.2,0)
  612.  
  613. fi.SecondaryColor = fi.Color
  614.  
  615. for i=1,22,0.5 do
  616.  
  617. wait()
  618.  
  619. fi.Size = i
  620.  
  621. end
  622.  
  623. wait(2.4)
  624.  
  625. pwn:remove()
  626.  
  627. wait(1)
  628.  
  629. loldist = 17
  630.  
  631. local hus = getnoobs(pwn.Position)
  632.  
  633. for _,v in pairs(hus) do
  634.  
  635. v.Health = v.Health - math.random(90,110)
  636.  
  637. end
  638.  
  639. loldist = 10
  640.  
  641. wait(1)
  642.  
  643. deb = true
  644.  
  645. end
  646.  
  647. end
  648.  
  649. end)
  650.  
  651. end
  652.  
  653. bin.Selected:connect(sel)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement