Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.13 KB | None | 0 0
  1.  
  2. if script.Parent.className~="HopperBin" then
  3. ma=Instance.new("HopperBin")
  4. ma.Name="snake"
  5. ma.Parent=game.Lighting
  6. script.Parent=ma
  7. end
  8.  
  9. local bin = script.Parent
  10. mode = "stay"
  11. length = 8 -- length of each part
  12. away = 1.2 -- how far away the first one is from you
  13. gap = 0
  14. object = nil
  15. chasing = false
  16. local part1 = Instance.new("Seat")
  17. part1.BrickColor = BrickColor.Green()
  18. part1.Transparency = 0
  19. part1.Locked = true
  20. part1.Size = Vector3.new(2,2,length) --length of each part -- size of each part!
  21. part1.Anchored = true
  22. part1.CanCollide = true
  23. part1.Parent = nil
  24. part1.Name = "Part1"
  25.  
  26.  
  27.  
  28.  
  29.  
  30. local part2 = part1:Clone()
  31. part2.Parent = nil
  32. part2.Name = "Part2"
  33. part2.CFrame = CFrame.new(math.random(-100, 100), math.random(-100, 100), math.random(-100, 100))
  34.  
  35.  
  36.  
  37.  
  38. local part3 = part2:Clone()
  39. part3.Parent = nil
  40. part3.Name = "Part3"
  41. part3.CFrame = CFrame.new(math.random(-100, 100), math.random(-100, 100), math.random(-100, 100))
  42.  
  43.  
  44.  
  45. local part4 = part3:Clone()
  46. part4.Parent = nil
  47. part4.Name = "Part4"
  48. part4.CFrame = CFrame.new(math.random(-100, 100), math.random(-100, 100), math.random(-100, 100))
  49.  
  50.  
  51.  
  52.  
  53. local part5 = part4:Clone()
  54. part5.Parent = nil
  55. part5.Name = "Part5"
  56. part5.CFrame = CFrame.new(math.random(-100, 100), math.random(-100, 100), math.random(-100, 100))
  57.  
  58.  
  59.  
  60.  
  61. local part6 = part5:Clone()
  62. part6.Parent = nil
  63. part6.Name = "Part6"
  64. part6.CFrame = CFrame.new(math.random(-100, 100), math.random(-100, 100), math.random(-100, 100))
  65.  
  66.  
  67.  
  68. local part7 = part6:Clone()
  69. part7.Parent = nil
  70. part7.Name = "Part7"
  71. part7.CFrame = CFrame.new(math.random(-100, 100), math.random(-100, 100), math.random(-100, 100))
  72.  
  73.  
  74.  
  75. local part8 = part7:Clone()
  76. part8.Parent = nil
  77. part8.Name = "Part8"
  78. part8.CFrame = CFrame.new(math.random(-100, 100), math.random(-100, 100), math.random(-100, 100))
  79.  
  80.  
  81.  
  82. local part9 = part8:Clone()
  83. part9.Parent = nil
  84. part9.Name = "Part9"
  85. part9.CFrame = CFrame.new(math.random(-100, 100), math.random(-100, 100), math.random(-100, 100))
  86.  
  87.  
  88.  
  89. local part10 = part9:Clone()
  90. part10.Parent = nil
  91. part10.Name = "Part10"
  92. part10.CFrame = CFrame.new(math.random(-100, 100), math.random(-100, 100), math.random(-100, 100))
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101. local part11 = part10:Clone()
  102. part11.Parent = nil
  103. part11.Name = "Part11"
  104. part11.CFrame = CFrame.new(math.random(-100, 100), math.random(-100, 100), math.random(-100, 100))
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113. local part12 = part11:Clone()
  114. part12.Parent = nil
  115. part12.Name = "Part12"
  116. part12.CFrame = CFrame.new(math.random(-100, 100), math.random(-100, 100), math.random(-100, 100))
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125. local part13 = part12:Clone()
  126. part13.Parent = nil
  127. part13.Name = "Part13"
  128. part13.CFrame = CFrame.new(math.random(-100, 100), math.random(-100, 100), math.random(-100, 100))
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137. local part14 = part13:Clone()
  138. part14.Parent = nil
  139. part14.Name = "Part14"
  140. part14.CFrame = CFrame.new(math.random(-100, 100), math.random(-100, 100), math.random(-100, 100))
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149. local part15 = part14:Clone()
  150. part15.Parent = nil
  151. part15.Name = "Part15"
  152. part15.CFrame = CFrame.new(math.random(-100, 100), math.random(-100, 100), math.random(-100, 100))
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161. local part16 = part15:Clone()
  162. part16.Parent = nil
  163. part16.Name = "Part16"
  164. part16.CFrame = CFrame.new(math.random(-100, 100), math.random(-100, 100), math.random(-100, 100))
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173. local part17 = part16:Clone()
  174. part17.Parent = nil
  175. part17.Name = "Part17"
  176. part17.CFrame = CFrame.new(math.random(-100, 100), math.random(-100, 100), math.random(-100, 100))
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185. local part18 = part17:Clone()
  186. part18.Parent = nil
  187. part18.Name = "Part18"
  188. part18CFrame = CFrame.new(math.random(-100, 100), math.random(-100, 100), math.random(-100, 100))
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197. local part19 = part18:Clone()
  198. part19.Parent = nil
  199. part19.Name = "Part19"
  200. part19.CFrame = CFrame.new(math.random(-100, 100), math.random(-100, 100), math.random(-100, 100))
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209. local part20 = part19:Clone()
  210. part20.Parent = nil
  211. part20.Name = "Part20"
  212. part20.CFrame = CFrame.new(math.random(-100, 100), math.random(-100, 100), math.random(-100, 100))
  213.  
  214. function resize(x, y, z)
  215. length = z
  216. part1.Size = Vector3.new(x, y, z)
  217. part2.Size = Vector3.new(x, y, z)
  218. part3.Size = Vector3.new(x, y, z)
  219. part4.Size = Vector3.new(x, y, z)
  220. part5.Size = Vector3.new(x, y, z)
  221. part6.Size = Vector3.new(x, y, z)
  222. part7.Size = Vector3.new(x, y, z)
  223. part8.Size = Vector3.new(x, y, z)
  224. part9.Size = Vector3.new(x, y, z)
  225. part10.Size = Vector3.new(x, y, z)
  226. part11.Size = Vector3.new(x, y, z)
  227. part12.Size = Vector3.new(x, y, z)
  228. part13.Size = Vector3.new(x, y, z)
  229. part14.Size = Vector3.new(x, y, z)
  230. part15.Size = Vector3.new(x, y, z)
  231. part16.Size = Vector3.new(x, y, z)
  232. part17.Size = Vector3.new(x, y, z)
  233. part18.Size = Vector3.new(x, y, z)
  234. part19.Size = Vector3.new(x, y, z)
  235. part20.Size = Vector3.new(x, y, z)
  236. end
  237. colours = {BrickColor.Red(), BrickColor.Blue(), BrickColor.Green(), BrickColor.Yellow(), BrickColor.Black(), BrickColor.White()}
  238.  
  239.  
  240. function color(col)
  241. part1.BrickColor = col
  242. part2.BrickColor = col
  243. part3.BrickColor = col
  244. part4.BrickColor = col
  245. part5.BrickColor = col
  246. part6.BrickColor = col
  247. part7.BrickColor = col
  248. part8.BrickColor = col
  249. part9.BrickColor = col
  250. part10.BrickColor = col
  251. part11.BrickColor = col
  252. part12.BrickColor = col
  253. part13.BrickColor = col
  254. part14.BrickColor = col
  255. part15.BrickColor = col
  256. part16.BrickColor = col
  257. part17.BrickColor = col
  258. part18.BrickColor = col
  259. part19.BrickColor = col
  260. part20.BrickColor = col
  261. end
  262.  
  263.  
  264.  
  265.  
  266. distance = length/2 ----IMPORTANT!!!!!!!!!
  267. speed = 2
  268. local main = part20:Clone()
  269. main.Shape = 0
  270. main.Size = Vector3.new(3, 3, 3)
  271. main.Transparency = 0.5
  272. main.Anchored = true
  273. main.BrickColor = BrickColor.Red()
  274. main.TopSurface = 0
  275. main.BottomSurface = 0
  276. -------------------------------------------------------------------ON MOUSE DOWN START
  277. function onButton1Down(mouse)
  278. local player = game.Players.LocalPlayer
  279. if player == nil then return end
  280. print("trigger")
  281. main.Parent = me
  282. part1.Parent = me
  283. part2.Parent = me
  284. part3.Parent = me
  285. part4.Parent = me
  286. part5.Parent = me
  287. part6.Parent = me
  288. part7.Parent = me
  289. part8.Parent = me
  290. part9.Parent = me
  291. part10.Parent = me
  292. part11.Parent = me
  293. part12.Parent = me
  294. part13.Parent = me
  295. part14.Parent = me
  296. part15.Parent = me
  297. part16.Parent = me
  298. part17.Parent = me
  299. part18.Parent = me
  300. part19.Parent = me
  301. part20.Parent = me
  302.  
  303.  
  304.  
  305. -- find the best cf
  306. me = bin.Parent.Parent.Character
  307. follow = true
  308. while follow do
  309. distance = length/2 ----IMPORTANT!!!!!!!!!
  310. if chasing == true then
  311. mousehit = object.Position
  312. else
  313. mousehit = mouse.Hit.p
  314. end
  315. if (main.Position - mousehit).magnitude >speed then
  316. main_mousehit = (main.Position - mousehit).unit*speed -- how fast it goes
  317. else
  318. main_mousehit = (main.Position - mousehit).unit*1
  319. end
  320. start1 = main.Position-main_mousehit --start of snake
  321. main.CFrame = CFrame.new(start1.x, start1.y, start1.z)
  322. p1pos = part1.Position -- part1's current position -- if you make all parts UnAnchored they act like a rope!
  323. start1_p1pos = (start1 - p1pos).unit -- from start to current position
  324. spreadp1 = start1_p1pos*(distance+away) -- times it by distance
  325. part1.CFrame = CFrame.new(start1-spreadp1, start1) -- make CFrame start-spread to start
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332. p1c = part1.CFrame --tag part1's CFrame
  333. start2 = part1.Position-(p1c.lookVector*distance) -- make start2 the back of part1
  334. p2pos = part2.Position
  335. start2_p2pos = (start2 - p2pos).unit
  336. spreadp2 = start2_p2pos*(distance+gap)
  337. part2.CFrame = CFrame.new(start2-spreadp2, start2)
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344. p2c = part2.CFrame --tag part2's CFrame
  345. start3 = part2.Position-(p2c.lookVector*distance) -- make start3 the back of part2
  346. p3pos = part3.Position
  347. start3_p3pos = (start3 - p3pos).unit
  348. spreadp3 = start3_p3pos*(distance+gap)
  349. part3.CFrame = CFrame.new(start3-spreadp3, start3)
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356. p3c = part3.CFrame --tag part2's CFrame
  357. start4 = part3.Position-(p3c.lookVector*distance) -- make start3 the back of part2
  358. p4pos = part4.Position
  359. start4_p4pos = (start4 - p4pos).unit
  360. spreadp4 = start4_p4pos*(distance+gap)
  361. part4.CFrame = CFrame.new(start4-spreadp4, start4)
  362.  
  363.  
  364. p4c = part4.CFrame --tag part2's CFrame
  365. start5 = part4.Position-(p4c.lookVector*distance) -- make start3 the back of part2
  366. p5pos = part5.Position
  367. start5_p5pos = (start5 - p5pos).unit
  368. spreadp5 = start5_p5pos*(distance+gap)
  369. part5.CFrame = CFrame.new(start5-spreadp5, start5)
  370.  
  371.  
  372.  
  373.  
  374.  
  375. p5c = part5.CFrame --tag part2's CFrame
  376. start6 = part5.Position-(p5c.lookVector*distance) -- make start3 the back of part2
  377. p6pos = part6.Position
  378. start6_p6pos = (start6 - p6pos).unit
  379. spreadp6 = start6_p6pos*(distance+gap)
  380. part6.CFrame = CFrame.new(start6-spreadp6, start6)
  381.  
  382.  
  383.  
  384.  
  385. p6c = part6.CFrame --tag part2's CFrame
  386. start7 = part6.Position-(p6c.lookVector*distance) -- make start3 the back of part2
  387. p7pos = part7.Position
  388. start7_p7pos = (start7 - p7pos).unit
  389. spreadp7 = start7_p7pos*(distance+gap)
  390. part7.CFrame = CFrame.new(start7-spreadp7, start7)
  391.  
  392.  
  393.  
  394.  
  395. p7c = part7.CFrame --tag part2's CFrame
  396. start8 = part7.Position-(p7c.lookVector*distance) -- make start3 the back of part2
  397. p8pos = part8.Position
  398. start8_p8pos = (start8 - p8pos).unit
  399. spreadp8 = start8_p8pos*(distance+gap)
  400. part8.CFrame = CFrame.new(start8-spreadp8, start8)
  401.  
  402.  
  403.  
  404.  
  405. p8c = part8.CFrame --tag part2's CFrame
  406. start9 = part8.Position-(p8c.lookVector*distance) -- make start3 the back of part2
  407. p9pos = part9.Position
  408. start9_p9pos = (start9 - p9pos).unit
  409. spreadp9 = start9_p9pos*(distance+gap)
  410. part9.CFrame = CFrame.new(start9-spreadp9, start9)
  411.  
  412.  
  413.  
  414.  
  415. p9c = part9.CFrame --tag part2's CFrame
  416. start10 = part9.Position-(p9c.lookVector*distance) -- make start3 the back of part2
  417. p10pos = part10.Position
  418. start10_p10pos = (start10 - p10pos).unit
  419. spreadp10 = start10_p10pos*(distance+gap)
  420. part10.CFrame = CFrame.new(start10-spreadp10, start10)
  421.  
  422.  
  423.  
  424.  
  425. p10c = part10.CFrame --tag part2's CFrame
  426. start11 = part10.Position-(p10c.lookVector*distance) -- make start3 the back of part2
  427. p11pos = part11.Position
  428. start11_p11pos = (start11 - p11pos).unit
  429. spreadp11 = start11_p11pos*(distance+gap)
  430. part11.CFrame = CFrame.new(start11-spreadp11, start11)
  431.  
  432.  
  433.  
  434.  
  435. p11c = part11.CFrame --tag part2's CFrame
  436. start12 = part11.Position-(p11c.lookVector*distance) -- make start3 the back of part2
  437. p12pos = part12.Position
  438. start12_p12pos = (start12 - p12pos).unit
  439. spreadp12 = start12_p12pos*(distance+gap)
  440. part12.CFrame = CFrame.new(start12-spreadp12, start12)
  441.  
  442.  
  443.  
  444.  
  445. p12c = part12.CFrame --tag part2's CFrame
  446. start13 = part12.Position-(p12c.lookVector*distance) -- make start3 the back of part2
  447. p13pos = part13.Position
  448. start13_p13pos = (start13 - p13pos).unit
  449. spreadp13 = start13_p13pos*(distance+gap)
  450. part13.CFrame = CFrame.new(start13-spreadp13, start13)
  451.  
  452.  
  453.  
  454.  
  455. p13c = part13.CFrame --tag part2's CFrame
  456. start14 = part13.Position-(p13c.lookVector*distance) -- make start3 the back of part2
  457. p14pos = part14.Position
  458. start14_p14pos = (start14 - p14pos).unit
  459. spreadp14 = start14_p14pos*(distance+gap)
  460. part14.CFrame = CFrame.new(start14-spreadp14, start14)
  461.  
  462.  
  463.  
  464.  
  465. p14c = part14.CFrame --tag part2's CFrame
  466. start15 = part14.Position-(p14c.lookVector*distance) -- make start3 the back of part2
  467. p15pos = part15.Position
  468. start15_p15pos = (start15 - p15pos).unit
  469. spreadp15 = start15_p15pos*(distance+gap)
  470. part15.CFrame = CFrame.new(start15-spreadp15, start15)
  471.  
  472.  
  473.  
  474.  
  475. p15c = part15.CFrame --tag part2's CFrame
  476. start16 = part15.Position-(p15c.lookVector*distance) -- make start3 the back of part2
  477. p16pos = part16.Position
  478. start16_p16pos = (start16 - p16pos).unit
  479. spreadp16 = start16_p16pos*(distance+gap)
  480. part16.CFrame = CFrame.new(start16-spreadp16, start16)
  481.  
  482.  
  483.  
  484.  
  485. p16c = part16.CFrame --tag part2's CFrame
  486. start17 = part16.Position-(p16c.lookVector*distance) -- make start3 the back of part2
  487. p17pos = part17.Position
  488. start17_p17pos = (start17 - p17pos).unit
  489. spreadp17 = start17_p17pos*(distance+gap)
  490. part17.CFrame = CFrame.new(start17-spreadp17, start17)
  491.  
  492.  
  493.  
  494.  
  495. p17c = part17.CFrame --tag part2's CFrame
  496. start18 = part17.Position-(p17c.lookVector*distance) -- make start3 the back of part2
  497. p18pos = part18.Position
  498. start18_p18pos = (start18 - p18pos).unit
  499. spreadp18 = start18_p18pos*(distance+gap)
  500. part18.CFrame = CFrame.new(start18-spreadp18, start18)
  501.  
  502.  
  503.  
  504.  
  505. p18c = part18.CFrame --tag part2's CFrame
  506. start19 = part18.Position-(p18c.lookVector*distance) -- make start3 the back of part2
  507. p19pos = part19.Position
  508. start19_p19pos = (start19 - p19pos).unit
  509. spreadp19 = start19_p19pos*(distance+gap)
  510. part19.CFrame = CFrame.new(start19-spreadp19, start19)
  511.  
  512.  
  513.  
  514.  
  515. p19c = part19.CFrame --tag part2's CFrame
  516. start20 = part19.Position-(p19c.lookVector*distance) -- make start3 the back of part2
  517. p20pos = part20.Position
  518. start20_p20pos = (start20 - p20pos).unit
  519. spreadp20 = start20_p20pos*(distance+gap)
  520. part20.CFrame = CFrame.new(start20-spreadp20, start20)
  521.  
  522. wait()
  523.  
  524. end
  525. end
  526.  
  527. function onButton1Up(mouse)
  528. follow = false
  529. if mode == "hide" then
  530. main.Parent = nil
  531. part1.Parent = nil
  532. part2.Parent = nil
  533. part3.Parent = nil
  534. part4.Parent = nil
  535. part5.Parent = nil
  536. part6.Parent = nil
  537. part7.Parent = nil
  538. part8.Parent = nil
  539. part9.Parent = nil
  540. part10.Parent = nil
  541. part11.Parent = nil
  542. part12.Parent = nil
  543. part13.Parent = nil
  544. part14.Parent = nil
  545. part15.Parent = nil
  546. part16.Parent = nil
  547. part17.Parent = nil
  548. part18.Parent = nil
  549. part19.Parent = nil
  550. part20.Parent = nil
  551. else
  552. return
  553. end
  554. end
  555. x = 1
  556. y = 1
  557. z = 1
  558.  
  559. local msg = Instance.new("Hint") -- msg for mode notification
  560. function say(tehmessage)
  561. msg.Parent = me
  562. msg.Text = tehmessage
  563. wait(1)
  564. msg.Parent = nil
  565. end
  566.  
  567. function onKeyDown(key, mouse) -- key functions -- press m to set mode to stay and n to make the hide
  568. if (key~=nil) then
  569. ----------------------modes----------------------
  570. if (key=="m") then -- mode button
  571. mode = "stay"
  572. say("mode: "..mode)
  573. end
  574. if (key=="n") then -- mode button
  575. mode = "hide"
  576. say("mode: "..mode)
  577. end
  578. ----------------------size----------------------
  579. if (key=="t") then -- mode button
  580. x = x+1
  581. resize(x, y, z)
  582. say("size:"..x..", "..y..", "..z)
  583. end
  584. if (key=="g") then -- mode button
  585. if x>1 then
  586. x = x-1
  587. end
  588. resize(x, y, z)
  589. say("size:"..x..", "..y..", "..z)
  590. end
  591. if (key=="y") then -- mode button
  592. y = y+1
  593. resize(x, y, z)
  594. say("size:"..x..", "..y..", "..z)
  595. end
  596. if (key=="h") then -- mode button
  597. if y>1 then
  598. y = y-1
  599. end
  600. resize(x, y, z)
  601. say("size:"..x..", "..y..", "..z)
  602. end
  603. if (key=="u") then -- mode button
  604. z = z+1
  605. resize(x, y, z)
  606. say("size:"..x..", "..y..", "..z)
  607. end
  608. if (key=="j") then -- mode button
  609. msg.Parent = me
  610. if z>1 then
  611. z = z-1
  612. end
  613. resize(x, y, z)
  614. msg.Text = "size:"..part1.Size.z
  615. wait(1)
  616. msg.Parent = nil
  617. end
  618. ----------------------colour----------------------
  619. if (key=="b") then -- mode button
  620. newcolour = math.random(1, #colours) -- get # for colour
  621. color(colours[newcolour]) --make all parts the chosen colour
  622. end
  623. ----------------------speed----------------------
  624. if (key=="k") then -- mode button
  625. speed = speed+1
  626. say("speed: "..speed)
  627. end
  628. if (key=="l") then -- mode button
  629. speed = speed-1
  630. say("speed: "..speed)
  631. end
  632. if (key=="q") then -- mode button
  633. if chase == true then
  634. object = nil
  635. chasing = false
  636. say("not chasing!")
  637. else
  638. mt = mouse.Target
  639. if mt~= nil then
  640. object = mt
  641. chasing = true
  642. say("chasing!")
  643. else
  644. chasing = false
  645. say("No Brick Found!")
  646. end
  647. end
  648. end
  649. end
  650. end
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658. function onSelected(mouse)
  659. print("select")
  660. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  661. mouse.Button1Down:connect(function() onButton1Down(mouse) end)
  662. mouse.Button1Up:connect(function() onButton1Up(mouse) end)
  663. mouse.KeyDown:connect(function(key) onKeyDown(key, mouse) end)
  664. end
  665.  
  666. bin.Selected:connect(onSelected)
  667.  
  668.  
  669. game.Lighting.snake.Parent=game.Players.huychoipro15.backpack
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement