Advertisement
Chxp

Untitled

Jul 30th, 2015
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.83 KB | None | 0 0
  1. h = Instance.new("HopperBin")
  2. h.Parent = game.Players.Chxp.Backpack
  3. h.Name = "Snake"
  4.  
  5.  
  6. script.Parent = h
  7.  
  8.  
  9. local bin = script.Parent
  10. mode = "hide"
  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,1,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(),
  238.  
  239. BrickColor.White()}
  240.  
  241.  
  242. function color(col)
  243. part1.BrickColor = col
  244. part2.BrickColor = col
  245. part3.BrickColor = col
  246. part4.BrickColor = col
  247. part5.BrickColor = col
  248. part6.BrickColor = col
  249. part7.BrickColor = col
  250. part8.BrickColor = col
  251. part9.BrickColor = col
  252. part10.BrickColor = col
  253. part11.BrickColor = col
  254. part12.BrickColor = col
  255. part13.BrickColor = col
  256. part14.BrickColor = col
  257. part15.BrickColor = col
  258. part16.BrickColor = col
  259. part17.BrickColor = col
  260. part18.BrickColor = col
  261. part19.BrickColor = col
  262. part20.BrickColor = col
  263. end
  264.  
  265.  
  266.  
  267.  
  268. distance = length/2 ----IMPORTANT!!!!!!!!!
  269. speed = 2
  270. local main = part20:Clone()
  271. main.Shape = 0
  272. main.Size = Vector3.new(3, 3, 3)
  273. main.Transparency = 0.5
  274. main.Anchored = true
  275. main.BrickColor = BrickColor.Red()
  276. main.TopSurface = 0
  277. main.BottomSurface = 0
  278. -------------------------------------------------------------------ON MOUSE DOWN START
  279. function onButton1Down(mouse)
  280. local player = game.Players.LocalPlayer
  281. if player == nil then return end
  282. print("trigger")
  283. main.Parent = me
  284. part1.Parent = me
  285. part2.Parent = me
  286. part3.Parent = me
  287. part4.Parent = me
  288. part5.Parent = me
  289. part6.Parent = me
  290. part7.Parent = me
  291. part8.Parent = me
  292. part9.Parent = me
  293. part10.Parent = me
  294. part11.Parent = me
  295. part12.Parent = me
  296. part13.Parent = me
  297. part14.Parent = me
  298. part15.Parent = me
  299. part16.Parent = me
  300. part17.Parent = me
  301. part18.Parent = me
  302. part19.Parent = me
  303. part20.Parent = me
  304.  
  305.  
  306.  
  307. -- find the best cf
  308. me = bin.Parent.Parent.Character
  309. follow = true
  310. while follow do
  311. distance = length/2 ----IMPORTANT!!!!!!!!!
  312. if chasing == true then
  313. mousehit = object.Position
  314. else
  315. mousehit = mouse.Hit.p
  316. end
  317. if (main.Position - mousehit).magnitude >speed then
  318. main_mousehit = (main.Position - mousehit).unit*speed -- how fast it goes
  319. else
  320. main_mousehit = (main.Position - mousehit).unit*1
  321. end
  322. start1 = main.Position-main_mousehit --start of snake
  323. main.CFrame = CFrame.new(start1.x, start1.y, start1.z)
  324. p1pos = part1.Position -- part1's current position -- if you make all parts UnAnchored they act like a rope!
  325. start1_p1pos = (start1 - p1pos).unit -- from start to current position
  326. spreadp1 = start1_p1pos*(distance+away) -- times it by distance
  327. part1.CFrame = CFrame.new(start1-spreadp1, start1) -- make CFrame start-spread to start
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. p1c = part1.CFrame --tag part1's CFrame
  335. start2 = part1.Position-(p1c.lookVector*distance) -- make start2 the back of part1
  336. p2pos = part2.Position
  337. start2_p2pos = (start2 - p2pos).unit
  338. spreadp2 = start2_p2pos*(distance+gap)
  339. part2.CFrame = CFrame.new(start2-spreadp2, start2)
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346. p2c = part2.CFrame --tag part2's CFrame
  347. start3 = part2.Position-(p2c.lookVector*distance) -- make start3 the back of part2
  348. p3pos = part3.Position
  349. start3_p3pos = (start3 - p3pos).unit
  350. spreadp3 = start3_p3pos*(distance+gap)
  351. part3.CFrame = CFrame.new(start3-spreadp3, start3)
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358. p3c = part3.CFrame --tag part2's CFrame
  359. start4 = part3.Position-(p3c.lookVector*distance) -- make start3 the back of part2
  360. p4pos = part4.Position
  361. start4_p4pos = (start4 - p4pos).unit
  362. spreadp4 = start4_p4pos*(distance+gap)
  363. part4.CFrame = CFrame.new(start4-spreadp4, start4)
  364.  
  365.  
  366. p4c = part4.CFrame --tag part2's CFrame
  367. start5 = part4.Position-(p4c.lookVector*distance) -- make start3 the back of part2
  368. p5pos = part5.Position
  369. start5_p5pos = (start5 - p5pos).unit
  370. spreadp5 = start5_p5pos*(distance+gap)
  371. part5.CFrame = CFrame.new(start5-spreadp5, start5)
  372.  
  373.  
  374.  
  375.  
  376.  
  377. p5c = part5.CFrame --tag part2's CFrame
  378. start6 = part5.Position-(p5c.lookVector*distance) -- make start3 the back of part2
  379. p6pos = part6.Position
  380. start6_p6pos = (start6 - p6pos).unit
  381. spreadp6 = start6_p6pos*(distance+gap)
  382. part6.CFrame = CFrame.new(start6-spreadp6, start6)
  383.  
  384.  
  385.  
  386.  
  387. p6c = part6.CFrame --tag part2's CFrame
  388. start7 = part6.Position-(p6c.lookVector*distance) -- make start3 the back of part2
  389. p7pos = part7.Position
  390. start7_p7pos = (start7 - p7pos).unit
  391. spreadp7 = start7_p7pos*(distance+gap)
  392. part7.CFrame = CFrame.new(start7-spreadp7, start7)
  393.  
  394.  
  395.  
  396.  
  397. p7c = part7.CFrame --tag part2's CFrame
  398. start8 = part7.Position-(p7c.lookVector*distance) -- make start3 the back of part2
  399. p8pos = part8.Position
  400. start8_p8pos = (start8 - p8pos).unit
  401. spreadp8 = start8_p8pos*(distance+gap)
  402. part8.CFrame = CFrame.new(start8-spreadp8, start8)
  403.  
  404.  
  405.  
  406.  
  407. p8c = part8.CFrame --tag part2's CFrame
  408. start9 = part8.Position-(p8c.lookVector*distance) -- make start3 the back of part2
  409. p9pos = part9.Position
  410. start9_p9pos = (start9 - p9pos).unit
  411. spreadp9 = start9_p9pos*(distance+gap)
  412. part9.CFrame = CFrame.new(start9-spreadp9, start9)
  413.  
  414.  
  415.  
  416.  
  417. p9c = part9.CFrame --tag part2's CFrame
  418. start10 = part9.Position-(p9c.lookVector*distance) -- make start3 the back of part2
  419. p10pos = part10.Position
  420. start10_p10pos = (start10 - p10pos).unit
  421. spreadp10 = start10_p10pos*(distance+gap)
  422. part10.CFrame = CFrame.new(start10-spreadp10, start10)
  423.  
  424.  
  425.  
  426.  
  427. p10c = part10.CFrame --tag part2's CFrame
  428. start11 = part10.Position-(p10c.lookVector*distance) -- make start3 the back of part2
  429. p11pos = part11.Position
  430. start11_p11pos = (start11 - p11pos).unit
  431. spreadp11 = start11_p11pos*(distance+gap)
  432. part11.CFrame = CFrame.new(start11-spreadp11, start11)
  433.  
  434.  
  435.  
  436.  
  437. p11c = part11.CFrame --tag part2's CFrame
  438. start12 = part11.Position-(p11c.lookVector*distance) -- make start3 the back of part2
  439. p12pos = part12.Position
  440. start12_p12pos = (start12 - p12pos).unit
  441. spreadp12 = start12_p12pos*(distance+gap)
  442. part12.CFrame = CFrame.new(start12-spreadp12, start12)
  443.  
  444.  
  445.  
  446.  
  447. p12c = part12.CFrame --tag part2's CFrame
  448. start13 = part12.Position-(p12c.lookVector*distance) -- make start3 the back of part2
  449. p13pos = part13.Position
  450. start13_p13pos = (start13 - p13pos).unit
  451. spreadp13 = start13_p13pos*(distance+gap)
  452. part13.CFrame = CFrame.new(start13-spreadp13, start13)
  453.  
  454.  
  455.  
  456.  
  457. p13c = part13.CFrame --tag part2's CFrame
  458. start14 = part13.Position-(p13c.lookVector*distance) -- make start3 the back of part2
  459. p14pos = part14.Position
  460. start14_p14pos = (start14 - p14pos).unit
  461. spreadp14 = start14_p14pos*(distance+gap)
  462. part14.CFrame = CFrame.new(start14-spreadp14, start14)
  463.  
  464.  
  465.  
  466.  
  467. p14c = part14.CFrame --tag part2's CFrame
  468. start15 = part14.Position-(p14c.lookVector*distance) -- make start3 the back of part2
  469. p15pos = part15.Position
  470. start15_p15pos = (start15 - p15pos).unit
  471. spreadp15 = start15_p15pos*(distance+gap)
  472. part15.CFrame = CFrame.new(start15-spreadp15, start15)
  473.  
  474.  
  475.  
  476.  
  477. p15c = part15.CFrame --tag part2's CFrame
  478. start16 = part15.Position-(p15c.lookVector*distance) -- make start3 the back of part2
  479. p16pos = part16.Position
  480. start16_p16pos = (start16 - p16pos).unit
  481. spreadp16 = start16_p16pos*(distance+gap)
  482. part16.CFrame = CFrame.new(start16-spreadp16, start16)
  483.  
  484.  
  485.  
  486.  
  487. p16c = part16.CFrame --tag part2's CFrame
  488. start17 = part16.Position-(p16c.lookVector*distance) -- make start3 the back of part2
  489. p17pos = part17.Position
  490. start17_p17pos = (start17 - p17pos).unit
  491. spreadp17 = start17_p17pos*(distance+gap)
  492. part17.CFrame = CFrame.new(start17-spreadp17, start17)
  493.  
  494.  
  495.  
  496.  
  497. p17c = part17.CFrame --tag part2's CFrame
  498. start18 = part17.Position-(p17c.lookVector*distance) -- make start3 the back of part2
  499. p18pos = part18.Position
  500. start18_p18pos = (start18 - p18pos).unit
  501. spreadp18 = start18_p18pos*(distance+gap)
  502. part18.CFrame = CFrame.new(start18-spreadp18, start18)
  503.  
  504.  
  505.  
  506.  
  507. p18c = part18.CFrame --tag part2's CFrame
  508. start19 = part18.Position-(p18c.lookVector*distance) -- make start3 the back of part2
  509. p19pos = part19.Position
  510. start19_p19pos = (start19 - p19pos).unit
  511. spreadp19 = start19_p19pos*(distance+gap)
  512. part19.CFrame = CFrame.new(start19-spreadp19, start19)
  513.  
  514.  
  515.  
  516.  
  517. p19c = part19.CFrame --tag part2's CFrame
  518. start20 = part19.Position-(p19c.lookVector*distance) -- make start3 the back of part2
  519. p20pos = part20.Position
  520. start20_p20pos = (start20 - p20pos).unit
  521. spreadp20 = start20_p20pos*(distance+gap)
  522. part20.CFrame = CFrame.new(start20-spreadp20, start20)
  523.  
  524. wait()
  525.  
  526. end
  527. end
  528.  
  529. function onButton1Up(mouse)
  530. follow = false
  531. if mode == "hide" then
  532. main.Parent = nil
  533. part1.Parent = nil
  534. part2.Parent = nil
  535. part3.Parent = nil
  536. part4.Parent = nil
  537. part5.Parent = nil
  538. part6.Parent = nil
  539. part7.Parent = nil
  540. part8.Parent = nil
  541. part9.Parent = nil
  542. part10.Parent = nil
  543. part11.Parent = nil
  544. part12.Parent = nil
  545. part13.Parent = nil
  546. part14.Parent = nil
  547. part15.Parent = nil
  548. part16.Parent = nil
  549. part17.Parent = nil
  550. part18.Parent = nil
  551. part19.Parent = nil
  552. part20.Parent = nil
  553. else
  554. return
  555. end
  556. end
  557. x = 1
  558. y = 1
  559. z = 1
  560.  
  561. local msg = Instance.new("Hint") -- msg for mode notification
  562. function say(tehmessage)
  563. msg.Parent = me
  564. msg.Text = tehmessage
  565. wait(1)
  566. msg.Parent = nil
  567. end
  568.  
  569. function onKeyDown(key, mouse) -- key functions -- press m to set mode to stay and n to make the hide
  570. if (key~=nil) then
  571. ----------------------modes----------------------
  572. if (key=="m") then -- mode button
  573. mode = "stay"
  574. say("mode: "..mode)
  575. end
  576. if (key=="n") then -- mode button
  577. mode = "hide"
  578. say("mode: "..mode)
  579. end
  580. ----------------------size----------------------
  581. if (key=="t") then -- mode button
  582. x = x+1
  583. resize(x, y, z)
  584. say("size:"..x..", "..y..", "..z)
  585. end
  586. if (key=="g") then -- mode button
  587. if x>1 then
  588. x = x-1
  589. end
  590. resize(x, y, z)
  591. say("size:"..x..", "..y..", "..z)
  592. end
  593. if (key=="y") then -- mode button
  594. y = y+1
  595. resize(x, y, z)
  596. say("size:"..x..", "..y..", "..z)
  597. end
  598. if (key=="h") then -- mode button
  599. if y>1 then
  600. y = y-1
  601. end
  602. resize(x, y, z)
  603. say("size:"..x..", "..y..", "..z)
  604. end
  605. if (key=="u") then -- mode button
  606. z = z+1
  607. resize(x, y, z)
  608. say("size:"..x..", "..y..", "..z)
  609. end
  610. if (key=="j") then -- mode button
  611. msg.Parent = me
  612. if z>1 then
  613. z = z-1
  614. end
  615. resize(x, y, z)
  616. msg.Text = "size:"..part1.Size.z
  617. wait(1)
  618. msg.Parent = nil
  619. end
  620. ----------------------colour----------------------
  621. if (key=="b") then -- mode button
  622. newcolour = math.random(1, #colours) -- get # for colour
  623. color(colours[newcolour]) --make all parts the chosen colour
  624. end
  625. ----------------------speed----------------------
  626. if (key=="k") then -- mode button
  627. speed = speed+1
  628. say("speed: "..speed)
  629. end
  630. if (key=="l") then -- mode button
  631. speed = speed-1
  632. say("speed: "..speed)
  633. end
  634. if (key=="q") then -- mode button
  635. if chase == true then
  636. object = nil
  637. chasing = false
  638. say("not chasing!")
  639. else
  640. mt = mouse.Target
  641. if mt~= nil then
  642. object = mt
  643. chasing = true
  644. say("chasing!")
  645. else
  646. chasing = false
  647. say("No Brick Found!")
  648. end
  649. end
  650. end
  651. end
  652. end
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660. function onSelected(mouse)
  661. print("select")
  662. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  663. mouse.Button1Down:connect(function() onButton1Down(mouse) end)
  664. mouse.Button1Up:connect(function() onButton1Up(mouse) end)
  665. mouse.KeyDown:connect(function(key) onKeyDown(key, mouse) end)
  666. end
  667.  
  668. bin.Selected:connect(onSelected)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement