Advertisement
lafur

Untitled

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