Advertisement
aidanthescriptor101

snake

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