Upscalefanatic3

Zombies AI

Oct 5th, 2016
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.43 KB | None | 0 0
  1. model = script.Parent
  2. backup = model:Clone()
  3. regentime = 1 --5 minutes
  4.  
  5. ------------------
  6. --SPAWNING--
  7. ------------------
  8.  
  9. miked=script.Parent
  10.  
  11. itlh=miked.Torso:findFirstChild("Left Hip")
  12. itlh.Part0=miked.Torso
  13. itlh.Part1=miked:findFirstChild("Left Leg")
  14. itlh.C0=CFrame.new(-1, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  15.  
  16. itrh=miked.Torso:findFirstChild("Right Hip")
  17. itrh.Part0=miked.Torso
  18. itrh.Part1=miked:findFirstChild("Right Leg")
  19. itrh.C0=CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
  20.  
  21. itls=miked.Torso:findFirstChild("Left Shoulder")
  22. itls.Part1=miked.Torso
  23. itls.C0=CFrame.new(2, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  24. itls.Part0=miked:findFirstChild("Left Arm")
  25.  
  26. itrs=miked.Torso:findFirstChild("Right Shoulder")
  27. itrs.Part1=miked.Torso
  28. itrs.C0=CFrame.new(-2, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
  29. itrs.Part0=miked:findFirstChild("Right Arm")
  30.  
  31. miked.Head:makeJoints()
  32. ------------------
  33. ------------------
  34.  
  35.  
  36. function waitForChild(parent, childName)
  37. while true do
  38. local child = parent:findFirstChild(childName)
  39. if child then
  40. return child
  41. end
  42. parent.ChildAdded:wait()
  43. end
  44. end
  45.  
  46. local Figure = script.Parent
  47. local Torso = waitForChild(Figure, "Torso")
  48. local RightShoulder = waitForChild(Torso, "Right Shoulder")
  49. local LeftShoulder = waitForChild(Torso, "Left Shoulder")
  50. local RightHip = waitForChild(Torso, "Right Hip")
  51. local LeftHip = waitForChild(Torso, "Left Hip")
  52. local Neck = waitForChild(Torso, "Neck")
  53. local Humanoid = waitForChild(Figure, "Zombie")
  54. local pose = "Standing"
  55.  
  56. local toolAnim = "None"
  57. local toolAnimTime = 0
  58.  
  59. local isSeated = false
  60.  
  61.  
  62. function onRunning(speed)
  63. if isSeated then return end
  64.  
  65. if speed>0 then
  66. pose = "Running"
  67. else
  68. pose = "Standing"
  69. end
  70. end
  71.  
  72. function onDied()
  73. pose = "Dead"
  74. wait(regentime)
  75. wait(1)
  76. model:remove()
  77. model = backup:Clone()
  78. wait(3)
  79. model.Parent = game.Workspace
  80. model:MakeJoints()
  81. end
  82.  
  83. function onJumping()
  84. isSeated = false
  85. pose = "Jumping"
  86. end
  87.  
  88. function onClimbing()
  89. pose = "Climbing"
  90. end
  91.  
  92. function onGettingUp()
  93. pose = "GettingUp"
  94. end
  95.  
  96. function onFreeFall()
  97. pose = "FreeFall"
  98. end
  99.  
  100. function onDancing()
  101. pose = "Dancing"
  102. end
  103.  
  104. function onFallingDown()
  105. pose = "FallingDown"
  106. end
  107.  
  108. function onSeated()
  109. isSeated = true
  110. pose = "Seated"
  111. end
  112.  
  113.  
  114.  
  115. function moveJump()
  116. RightShoulder.MaxVelocity = 0.5
  117. LeftShoulder.MaxVelocity = 0.5
  118. RightShoulder.DesiredAngle = -3.14
  119. LeftShoulder.DesiredAngle = -3.14
  120. RightHip.DesiredAngle = 0
  121. LeftHip.DesiredAngle = 0
  122. end
  123.  
  124. function moveFreeFall()
  125. RightShoulder.MaxVelocity = 0.5
  126. LeftShoulder.MaxVelocity = 0.5
  127. RightShoulder.DesiredAngle = -1
  128. LeftShoulder.DesiredAngle = -1
  129. RightHip.DesiredAngle = 0
  130. LeftHip.DesiredAngle = 0
  131. end
  132.  
  133. function moveFloat()
  134. RightShoulder.MaxVelocity = 0.5
  135. LeftShoulder.MaxVelocity = 0.5
  136. RightShoulder.DesiredAngle = -1.57
  137. LeftShoulder.DesiredAngle = 1.57
  138. RightHip.DesiredAngle = 1.57
  139. LeftHip.DesiredAngle = -1.57
  140. end
  141.  
  142. function moveBoogy()
  143. while pose=="Boogy" do
  144. wait(.5)
  145. RightShoulder.MaxVelocity = 1
  146. LeftShoulder.MaxVelocity = 1
  147. RightShoulder.DesiredAngle = -3.14
  148. LeftShoulder.DesiredAngle = 0
  149. RightHip.DesiredAngle = 1.57
  150. LeftHip.DesiredAngle = 0
  151. wait(.5)
  152. RightShoulder.MaxVelocity = 1
  153. LeftShoulder.MaxVelocity = 1
  154. RightShoulder.DesiredAngle = 0
  155. LeftShoulder.DesiredAngle = -3.14
  156. RightHip.DesiredAngle = 0
  157. LeftHip.DesiredAngle = 1.57
  158. end
  159. end
  160.  
  161. function moveZombie()
  162. RightShoulder.MaxVelocity = 0.5
  163. LeftShoulder.MaxVelocity = 0.5
  164. RightShoulder.DesiredAngle = -1.57
  165. LeftShoulder.DesiredAngle = 1.57
  166. RightHip.DesiredAngle = 0
  167. LeftHip.DesiredAngle = 0
  168. end
  169.  
  170. function movePunch()
  171. script.Parent.Torso.Anchored=true
  172. RightShoulder.MaxVelocity = 60
  173. LeftShoulder.MaxVelocity = 0.5
  174. RightShoulder.DesiredAngle = -1.57
  175. LeftShoulder.DesiredAngle = 0
  176. RightHip.DesiredAngle = 0
  177. LeftHip.DesiredAngle = 0
  178. wait(1)
  179. script.Parent.Torso.Anchored=false
  180. pose="Standing"
  181.  
  182. end
  183.  
  184. function moveKick()
  185. RightShoulder.MaxVelocity = 0.5
  186. LeftShoulder.MaxVelocity = 0.5
  187. RightShoulder.DesiredAngle = 0
  188. LeftShoulder.DesiredAngle = 0
  189. RightHip.MaxVelocity = 40
  190. RightHip.DesiredAngle = 1.57
  191. LeftHip.DesiredAngle = 0
  192. wait(1)
  193. pose="Standing"
  194.  
  195. end
  196.  
  197. function moveFly()
  198. RightShoulder.MaxVelocity = 0.5
  199. LeftShoulder.MaxVelocity = 0.5
  200. RightShoulder.DesiredAngle = 0
  201. LeftShoulder.DesiredAngle = 0
  202. RightHip.MaxVelocity = 40
  203. RightHip.DesiredAngle = 1.57
  204. LeftHip.DesiredAngle = 0
  205. wait(1)
  206. pose="Standing"
  207.  
  208. end
  209.  
  210.  
  211. function moveClimb()
  212. RightShoulder.MaxVelocity = 0.5
  213. LeftShoulder.MaxVelocity = 0.5
  214. RightShoulder.DesiredAngle = -3.14
  215. LeftShoulder.DesiredAngle = 3.14
  216. RightHip.DesiredAngle = 0
  217. LeftHip.DesiredAngle = 0
  218. end
  219.  
  220. function moveSit()
  221. RightShoulder.MaxVelocity = 0.15
  222. LeftShoulder.MaxVelocity = 0.15
  223. RightShoulder.DesiredAngle = -3.14 /2
  224. LeftShoulder.DesiredAngle = -3.14 /2
  225. RightHip.DesiredAngle = 3.14 /2
  226. LeftHip.DesiredAngle = -3.14 /2
  227. end
  228.  
  229. function getTool()
  230.  
  231. kidTable = Figure:children()
  232. if (kidTable ~= nil) then
  233. numKids = #kidTable
  234. for i=1,numKids do
  235. if (kidTable[i].className == "Tool") then return kidTable[i] end
  236. end
  237. end
  238.  
  239. return nil
  240. end
  241.  
  242. function getToolAnim(tool)
  243.  
  244. c = tool:children()
  245. for i=1,#c do
  246. if (c[i].Name == "toolanim" and c[i].className == "StringValue") then
  247. return c[i]
  248. end
  249. end
  250. return nil
  251. end
  252.  
  253. function animateTool()
  254.  
  255. if (toolAnim == "None") then
  256. RightShoulder.DesiredAngle = -1.57
  257. return
  258. end
  259.  
  260. if (toolAnim == "Slash") then
  261. RightShoulder.MaxVelocity = 0.5
  262. RightShoulder.DesiredAngle = 0
  263. return
  264. end
  265.  
  266. if (toolAnim == "Lunge") then
  267. RightShoulder.MaxVelocity = 0.5
  268. LeftShoulder.MaxVelocity = 0.5
  269. RightHip.MaxVelocity = 0.5
  270. LeftHip.MaxVelocity = 0.5
  271. RightShoulder.DesiredAngle = -1.57
  272. LeftShoulder.DesiredAngle = 1.0
  273. RightHip.DesiredAngle = 1.57
  274. LeftHip.DesiredAngle = 1.0
  275. return
  276. end
  277. end
  278.  
  279. function move(time)
  280. local amplitude
  281. local frequency
  282.  
  283. if (pose == "Jumping") then
  284. moveJump()
  285. return
  286. end
  287.  
  288. if (pose == "Zombie") then
  289. moveZombie()
  290. return
  291. end
  292.  
  293. if (pose == "Boogy") then
  294. moveBoogy()
  295. return
  296. end
  297.  
  298. if (pose == "Float") then
  299. moveFloat()
  300. return
  301. end
  302.  
  303. if (pose == "Punch") then
  304. movePunch()
  305. return
  306. end
  307.  
  308. if (pose == "Kick") then
  309. moveKick()
  310. return
  311. end
  312.  
  313. if (pose == "Fly") then
  314. moveFly()
  315. return
  316. end
  317.  
  318. if (pose == "FreeFall") then
  319. moveFreeFall()
  320. return
  321. end
  322.  
  323. if (pose == "Climbing") then
  324. moveClimb()
  325. return
  326. end
  327.  
  328. if (pose == "Seated") then
  329. moveSit()
  330. return
  331. end
  332.  
  333. amplitude = 0.1
  334. frequency = 1
  335.  
  336. RightShoulder.MaxVelocity = 0.15
  337. LeftShoulder.MaxVelocity = 0.15
  338. if (pose == "Running") then
  339. amplitude = 1
  340. frequency = 9
  341. elseif (pose == "Dancing") then
  342. amplitude = 2
  343. frequency = 16
  344. end
  345.  
  346.  
  347. desiredAngle = amplitude * math.sin(time*frequency)
  348. if pose~="Dancing" then
  349. RightShoulder.DesiredAngle = -desiredAngle
  350. LeftShoulder.DesiredAngle = desiredAngle
  351. RightHip.DesiredAngle = -desiredAngle
  352. LeftHip.DesiredAngle = -desiredAngle
  353. else
  354. RightShoulder.DesiredAngle = desiredAngle
  355. LeftShoulder.DesiredAngle = desiredAngle
  356. RightHip.DesiredAngle = -desiredAngle
  357. LeftHip.DesiredAngle = -desiredAngle
  358. end
  359.  
  360.  
  361.  
  362. local tool = getTool()
  363.  
  364. if tool ~= nil then
  365.  
  366. animStringValueObject = getToolAnim(tool)
  367.  
  368. if animStringValueObject ~= nil then
  369. toolAnim = animStringValueObject.Value
  370. -- message recieved, delete StringValue
  371. animStringValueObject.Parent = nil
  372. toolAnimTime = time + .3
  373. end
  374.  
  375. if time > toolAnimTime then
  376. toolAnimTime = 0
  377. toolAnim = "None"
  378. end
  379.  
  380. animateTool()
  381.  
  382.  
  383. else
  384. toolAnim = "None"
  385. toolAnimTime = 0
  386. end
  387. end
  388.  
  389.  
  390. -- connect events
  391. -----------------------------------------------------------------------------------------------------------------------
  392.  
  393. function unequip()
  394. local items=script.Parent:children()
  395. for i=1, #items do
  396. if items[i].className=="Tool" then items[i]:remove() end
  397. end
  398. end
  399.  
  400. function onChatted(msg, recipient)
  401. msg = string.lower(msg)
  402.  
  403. if string.match(msg, string.lower(script.Parent.Name))~=nil or string.match(msg, "everyone") then
  404. if string.match(msg, "equip") then
  405. if game.Workspace:findFirstChild("Hub") then
  406. if string.match(msg, "rocket") then unequip()
  407. game.Workspace.Hub.Rocket:clone().Parent=script.Parent
  408. elseif string.match(msg, "slingshot") then unequip()
  409. game.Workspace.Hub.Slingshot:clone().Parent=script.Parent
  410. elseif string.match(msg, "sword") then unequip()
  411. game.Workspace.Hub.Sword:clone().Parent=script.Parent
  412. elseif string.match(msg, "pbg") then unequip()
  413. game.Workspace.Hub.PBG:clone().Parent=script.Parent
  414. elseif string.match(msg, "superball") then unequip()
  415. game.Workspace.Hub.Superball:clone().Parent=script.Parent
  416. elseif string.match(msg, "trowel") then unequip()
  417. game.Workspace.Hub.Trowel:clone().Parent=script.Parent
  418. elseif string.match(msg, "bomb") then unequip()
  419. game.Workspace.Hub.Bomb:clone().Parent=script.Parent
  420. end
  421. end
  422. end
  423. if string.match(msg, "unequip") then unequip() end
  424. if string.match(msg, "run") then onRunning(1) end
  425. if string.match(msg, "climb") then onClimbing() end
  426. if string.match(msg, "jump") then onJumping() end
  427. if string.match(msg, "zombie") then pose="Zombie" end
  428. if string.match(msg, "disco") then pose="Boogy" end
  429. if string.match(msg, "float") then pose="Float" end
  430. if string.match(msg, "punch") then pose="Punch" end
  431. if string.match(msg, "kick") then pose="Kick" end
  432. if string.match(msg, "fly") then pose="Fly" end
  433. if string.match(msg, "heal") then script.Parent.Humanoid.Health=script.Parent.Humanoid.MaxHealth end
  434. if string.match(msg, "defend") then defence() end
  435. if string.match(msg, "stop") then pose="Standing"; proxkill=false; following=false; stopmoving() end
  436. if string.match(msg, "go home") then following=false; gohome() end
  437. if string.match(msg, "follow") then
  438. if string.match(msg, "all") then
  439. followany()
  440. else
  441. local egg=game.Players:children()
  442. for i=1, #egg do
  443. if string.match(msg, string.lower(egg[i].Name)) then
  444. follow(egg[i].Name)
  445. return
  446. end
  447. end
  448. end
  449. end
  450. if string.match(msg, "kill") then
  451. if string.match(msg, "all") then
  452. attackany()
  453. else
  454. local egg=game.Players:children()
  455. for i=1, #egg do
  456. if string.match(msg, string.lower(egg[i].Name)) then
  457. attack(egg[i].Name)
  458. return
  459. end
  460. end
  461. end
  462. end
  463.  
  464. end
  465. end
  466.  
  467. if game.Players.NumPlayers>1 then
  468. x=game.Players:children()
  469.  
  470. for i=1, #x do
  471. if script.Parent:findFirstChild("Commander")~=nil then
  472. if script.Parent.Commander:children()~=nil or script.Parent.Commander:children()>0 then
  473. local ch=script.Parent.Commander:children()
  474. for i=1, #ch do
  475. if string.lower(ch[i].Name)==string.lower(x[i].Name) then
  476. x[i].Chatted:connect(function(msg, recipient) onChatted(msg, recipient) end)
  477. end
  478. end
  479. elseif string.lower(script.Parent.Commander.Value)==string.lower(x[i].Name) then
  480. x[i].Chatted:connect(function(msg, recipient) onChatted(msg, recipient) end)
  481. end
  482. else
  483. x[i].Chatted:connect(function(msg, recipient) onChatted(msg, recipient) end)
  484. end
  485. end
  486. end
  487.  
  488.  
  489. function onPlayerEntered(Player)
  490. while Player.Name==nil do
  491. wait(2)
  492. end
  493. if script.Parent:findFirstChild("Commander")~=nil then
  494. if script.Parent.Commander:children()~=nil or script.Parent.Commander:children()>0 then
  495. local ch=script.Parent.Commander:children()
  496. for i=1, #ch do
  497. if string.lower(ch[i].Name)==string.lower(Player.Name) then
  498. Player.Chatted:connect(function(msg, recipient) onChatted(msg, recipient) end)
  499. end
  500. end
  501. elseif string.lower(script.Parent.Commander.Value)==string.lower(Player.Name) then
  502. Player.Chatted:connect(function(msg, recipient) onChatted(msg, recipient) end)
  503. end
  504. else
  505. Player.Chatted:connect(function(msg, recipient) onChatted(msg, recipient) end)
  506. end
  507. end
  508.  
  509. game.Players.ChildAdded:connect(onPlayerEntered)
  510.  
  511.  
  512.  
  513. -----------------------------------------------------------------------------------------------------------------------
  514. -----------------------------------------------------------------------------------------------------------------------
  515. -----------------------------------------------------------------------------------------------------------------------
  516. -----------------------------------------------------------------------------------------------------------------------
  517. -----------------------------------------------------------------------------------------------------------------------
  518. -----------------------------------------------------------------------------------------------------------------------
  519. -----------------------------------------------------------------------------------------------------------------------
  520. -----------------------------------------------------------------------------------------------------------------------
  521. -----------------------------------------------------------------------------------------------------------------------
  522. -----------------------------------------------------------------------------------------------------------------------
  523. -----------------------------------------------------------------------------------------------------------------------
  524. -----------------------------------------------------------------------------------------------------------------------
  525. dist=20
  526.  
  527. function followany()
  528. following=true
  529. while following==true do
  530.  
  531. local ch=game.Players:children()
  532. for i=1, #ch do
  533. local l=game.Workspace:findFirstChild(ch[i].Name)
  534. if l~=nil then
  535. local s=l.Torso
  536. local p=l.Torso.Position
  537. local q=script.Parent.Torso.Position
  538. local d=math.sqrt( ((p.x-q.x)^2)+((p.y-q.y)^2)+((p.z-q.z)^2) )
  539. if smallest==nil then
  540. smallest=d
  541. target=s
  542. elseif d<smallest then
  543. smallest=d
  544. target=s
  545. end
  546. end
  547. end
  548.  
  549. if smallest==nil then stopmoving() return end
  550.  
  551. if smallest>6*dist then return end
  552.  
  553. script.Parent.Humanoid:MoveTo(target.Position, target)
  554.  
  555. wait(0.5)
  556. for i=1, 6 do
  557. if target.Parent.Humanoid.Health<1 then stopmoving() else wait(0.5) end
  558. end
  559. end
  560. end
  561.  
  562.  
  563.  
  564. function gohome()
  565. script.Parent.Humanoid:MoveTo(Vector3.new(0,0,0), game.Workspace.Bases.Base)
  566. end
  567. function stopmoving()
  568. script.Parent.Humanoid:MoveTo(script.Parent.Torso.Position, script.Parent.Torso)
  569. end
  570.  
  571. function follow(name)
  572. following=true
  573.  
  574. local p=game.Workspace:findFirstChild(name)
  575. if p==nil then return end
  576. while following==true do
  577. script.Parent.Humanoid:MoveTo(p.Torso.Position, p.Torso)
  578. wait(0.5)
  579. for i=1, 3 do
  580. if p.Humanoid.Health<1 then following=false; stopmoving() return end
  581. wait(0.5)
  582. end
  583. end
  584. end
  585.  
  586. function attack(name)
  587. if script.Parent:findFirstChild("Sword")~=nil then
  588. following=true
  589. local p=game.Workspace:findFirstChild(name)
  590. if p==nil then return end
  591. while following==true do
  592. script.Parent.Humanoid:MoveTo(p.Torso.Position, p.Torso)
  593. wait(0.5)
  594. for i=1, 3 do
  595. if p.Humanoid.Health<1 then following=false; stopmoving() return end
  596. local l=p.Torso.Position
  597. local q=script.Parent.Torso.Position
  598. local d=math.sqrt( ((l.x-q.x)^2)+((l.y-q.y)^2)+((l.z-q.z)^2) )
  599. if d<10 then
  600. script.Parent.Humanoid:MoveTo(p.Torso.Position, p.Torso); slash()
  601. if (q.y-l.y)>3 and (q.y-l.y)<7 then
  602. script.Parent.Humanoid:MoveTo(p.Torso.Position+Vector3.new(math.random(-4,4),0,math.random(-4,4)), p.Torso);
  603. end
  604. end
  605. wait(1)
  606. end
  607. end
  608. end
  609. end
  610.  
  611. function attackany()
  612. if script.Parent:findFirstChild("Sword")~=nil then
  613.  
  614. following=true
  615. while following==true do
  616.  
  617. local ch=game.Players:children()
  618. for i=1, #ch do
  619. local l=game.Workspace:findFirstChild(ch[i].Name)
  620. if l~=nil then
  621. local s=l.Torso
  622. local p=l.Torso.Position
  623. local q=script.Parent.Torso.Position
  624. local d=math.sqrt( ((p.x-q.x)^2)+((p.y-q.y)^2)+((p.z-q.z)^2) )
  625. if smallest==nil then
  626. smallest=d
  627. target=s
  628. elseif d<smallest then
  629. smallest=d
  630. target=s
  631. end
  632. end
  633. end
  634.  
  635. if smallest==nil then stopmoving() return end
  636.  
  637. if smallest>6*dist then return end
  638.  
  639. script.Parent.Humanoid:MoveTo(target.Position, target)
  640.  
  641. if smallest<10 then
  642. slash()
  643. end
  644. if target.Parent==nil then stopmoving() return end
  645. wait(0.5)
  646. for i=1, 3 do
  647. if target.Parent.Humanoid.Health<1 then
  648. stopmoving()
  649. else
  650. local p=target.Position
  651. local q=script.Parent.Torso.Position
  652. local d=math.sqrt( ((p.x-q.x)^2)+((p.y-q.y)^2)+((p.z-q.z)^2) )
  653. if d<10 then
  654. script.Parent.Humanoid:MoveTo(target.Position, target); slash()
  655. if (q.y-p.y)>3 and (q.y-p.y)<7 then
  656. script.Parent.Humanoid:MoveTo(p.Torso.Position+Vector3.new(math.random(-4,4),0,math.random(-4,4)), p.Torso);
  657. end
  658. end
  659. wait(1)
  660. end
  661. end
  662. end
  663. end
  664. end
  665.  
  666.  
  667. function patrol()
  668. if points==nil then
  669. points=0
  670. if game.Workspace:findFirstChild("pp1")~=nil then
  671. pp1=game.Workspace:findFirstChild("pp1")
  672. local points=points+1
  673. if game.Workspace:findFirstChild("pp2")~=nil then
  674. pp2=game.Workspace:findFirstChild("pp2")
  675. local points=points+1
  676. if game.Workspace:findFirstChild("pp3")~=nil then
  677. pp3=game.Workspace:findFirstChild("pp3")
  678. local points=points+1
  679. if game.Workspace:findFirstChild("pp4")~=nil then
  680. pp4=game.Workspace:findFirstChild("pp4")
  681. local points=points+1
  682. if game.Workspace:findFirstChild("pp5")~=nil then
  683. pp5=game.Workspace:findFirstChild("pp5")
  684. local points=points+1
  685. if game.Workspace:findFirstChild("pp6")~=nil then
  686. pp6=game.Workspace:findFirstChild("pp6")
  687. local points=points+1
  688. if game.Workspace:findFirstChild("pp7")~=nil then
  689. pp7=game.Workspace:findFirstChild("pp7")
  690. local points=points+1
  691. if game.Workspace:findFirstChild("pp8")~=nil then
  692. pp8=game.Workspace:findFirstChild("pp8")
  693. local points=points+1
  694. if game.Workspace:findFirstChild("pp9")~=nil then
  695. pp9=game.Workspace:findFirstChild("pp9")
  696. local points=points+1
  697. end
  698. end
  699. end
  700. end
  701. end
  702. end
  703. end
  704. end
  705. end
  706. end
  707.  
  708. if points<1 then return end
  709. patrolling=true
  710. local time=2
  711. if points==1 then return end
  712. if points>1 then
  713. while patrolling==true do
  714. script.Parent.Humanoid:MoveTo(pp1.Position, pp1)
  715. wait(time)
  716. script.Parent.Humanoid:MoveTo(pp2.Position, pp2)
  717. wait(time)
  718. if points>2 then
  719. script.Parent.Humanoid:MoveTo(pp3.Position, pp3)
  720. wait(time)
  721. if points>3 then
  722. script.Parent.Humanoid:MoveTo(pp4.Position, pp4)
  723. wait(time)
  724. if points>4 then
  725. script.Parent.Humanoid:MoveTo(pp5.Position, pp5)
  726. wait(time)
  727. if points>5 then
  728. script.Parent.Humanoid:MoveTo(pp6.Position, pp6)
  729. wait(time)
  730. if points>6 then
  731. script.Parent.Humanoid:MoveTo(pp7.Position, pp7)
  732. wait(time)
  733. if points>7 then
  734. script.Parent.Humanoid:MoveTo(pp8.Position, pp8)
  735. wait(time)
  736. if points>8 then
  737. script.Parent.Humanoid:MoveTo(pp9.Position, pp9)
  738. wait(time)
  739. end
  740. end
  741. end
  742. end
  743. end
  744. end
  745. end
  746. end
  747. end
  748. end
  749.  
  750.  
  751. function goto(pos,part)
  752. while true do
  753. end
  754. end
  755.  
  756.  
  757. function slash()
  758. for i=1, 3 do
  759. wait(.3)
  760. RightShoulder.MaxVelocity = 2
  761. LeftShoulder.MaxVelocity = 1
  762. RightShoulder.DesiredAngle = -2.14
  763. LeftShoulder.DesiredAngle = 0
  764. RightHip.DesiredAngle = 0
  765. LeftHip.DesiredAngle = 0
  766. wait(.2)
  767. RightShoulder.MaxVelocity = 2
  768. LeftShoulder.MaxVelocity = 1
  769. RightShoulder.DesiredAngle = 0
  770. LeftShoulder.DesiredAngle = 0
  771. RightHip.DesiredAngle = 0
  772. LeftHip.DesiredAngle = 0
  773. end
  774. end
  775.  
  776. function defence()
  777. proxkill=true
  778. while proxkill==true do
  779. local ch=game.Players:children()
  780. for i=1, #ch do
  781. local p=game.Workspace:findFirstChild(ch[i].Name)
  782. if p~=nil then
  783. local p=p.Torso.Position
  784. local q=script.Parent.Torso.Position
  785. local d=math.sqrt( ((p.x-q.x)^2)+((p.y-q.y)^2)+((p.z-q.z)^2) )
  786. if d<dist and d>8 then
  787. local ex=Instance.new("Explosion")
  788. ex.Position=p
  789. ex.Parent=game.Workspace
  790. end
  791. end
  792. end
  793. wait(1)
  794. end
  795. end
  796.  
  797.  
  798.  
  799.  
  800. -----------------------------------------------------------------------------------------------------------------------
  801. -----------------------------------------------------------------------------------------------------------------------
  802. -----------------------------------------------------------------------------------------------------------------------
  803. -----------------------------------------------------------------------------------------------------------------------
  804. -----------------------------------------------------------------------------------------------------------------------
  805. -----------------------------------------------------------------------------------------------------------------------
  806. -----------------------------------------------------------------------------------------------------------------------
  807. -----------------------------------------------------------------------------------------------------------------------
  808. -----------------------------------------------------------------------------------------------------------------------
  809. -----------------------------------------------------------------------------------------------------------------------
  810. -----------------------------------------------------------------------------------------------------------------------
  811. -----------------------------------------------------------------------------------------------------------------------
  812.  
  813.  
  814. Humanoid.Died:connect(onDied)
  815. Humanoid.Running:connect(onRunning)
  816. Humanoid.Jumping:connect(onJumping)
  817. Humanoid.Climbing:connect(onClimbing)
  818. Humanoid.GettingUp:connect(onGettingUp)
  819. Humanoid.FreeFalling:connect(onFreeFall)
  820. Humanoid.FallingDown:connect(onFallingDown)
  821. Humanoid.Seated:connect(onSeated)
  822.  
  823.  
  824. --[[
  825.  
  826. function newSound(id)
  827. local sound = Instance.new("Sound")
  828. sound.SoundId = id
  829. sound.Parent = script.Parent.Head
  830. return sound
  831. end
  832.  
  833.  
  834. local sDied = newSound("rbxasset://sounds/uuhhh.wav")
  835. local sFallingDown = newSound("rbxasset://sounds/splat.wav")
  836. local sFreeFalling = newSound("rbxasset://sounds/swoosh.wav")
  837. local sGettingUp = newSound("rbxasset://sounds/hit.wav")
  838. local sJumping = newSound("rbxasset://sounds/button.wav")
  839. local sRunning = newSound("rbxasset://sounds/bfsl-minifigfoots1.mp3")
  840. sRunning.Looped = true
  841.  
  842. local Figure = script.Parent
  843. local Head = waitForChild(Figure, "Head")
  844. local Humanoid = waitForChild(Figure, "Humanoid")
  845.  
  846.  
  847. function onDied()
  848. sDied:play()
  849. end
  850.  
  851. function onState(state, sound)
  852. if state then
  853. sound:play()
  854. else
  855. sound:pause()
  856. end
  857. end
  858.  
  859. function onRunning(speed)
  860. if speed>0 then
  861. sRunning:play()
  862. else
  863. sRunning:pause()
  864. end
  865. end
  866.  
  867.  
  868. Humanoid.Died:connect(onDied)
  869. Humanoid.Running:connect(onRunning)
  870. Humanoid.Jumping:connect(function(state) onState(state, sJumping) end)
  871. Humanoid.GettingUp:connect(function(state) onState(state, sGettingUp) end)
  872. Humanoid.FreeFalling:connect(function(state) onState(state, sFreeFalling) end)
  873. Humanoid.FallingDown:connect(function(state) onState(state, sFallingDown) end)
  874. --]]
  875.  
  876. local nextTime = 0
  877. local runService = game:service("RunService");
  878.  
  879. while Figure.Parent~=nil do
  880. time = runService.Stepped:wait()
  881. if time > nextTime then
  882. move(time)
  883. nextTime = time + 0.1
  884. end
  885. end
Add Comment
Please, Sign In to add comment