Advertisement
BNutty07

Untitled

Nov 4th, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.84 KB | None | 0 0
  1.  
  2. --Converted with ttyyuu12345's model to script plugin v4
  3. function sandbox(var,func)
  4. local env = getfenv(func)
  5. local newenv = setmetatable({},{
  6. __index = function(self,k)
  7. if k=="script" then
  8. return var
  9. else
  10. return env[k]
  11. end
  12. end,
  13. })
  14. setfenv(func,newenv)
  15. return func
  16. end
  17. cors = {}
  18. mas = Instance.new("Model",game:GetService("Lighting"))
  19. Model0 = Instance.new("Model")
  20. Part1 = Instance.new("Part")
  21. SpecialMesh2 = Instance.new("SpecialMesh")
  22. Sound3 = Instance.new("Sound")
  23. Sound4 = Instance.new("Sound")
  24. Sound5 = Instance.new("Sound")
  25. Sound6 = Instance.new("Sound")
  26. Sound7 = Instance.new("Sound")
  27. Sound8 = Instance.new("Sound")
  28. Sound9 = Instance.new("Sound")
  29. Sound10 = Instance.new("Sound")
  30. Sound11 = Instance.new("Sound")
  31. Sound12 = Instance.new("Sound")
  32. Sound13 = Instance.new("Sound")
  33. Script14 = Instance.new("Script")
  34. Weld15 = Instance.new("Weld")
  35. Weld16 = Instance.new("Weld")
  36. Weld17 = Instance.new("Weld")
  37. Weld18 = Instance.new("Weld")
  38. Part19 = Instance.new("Part")
  39. Motor20 = Instance.new("Motor")
  40. Motor21 = Instance.new("Motor")
  41. Motor22 = Instance.new("Motor")
  42. Motor23 = Instance.new("Motor")
  43. Motor24 = Instance.new("Motor")
  44. Part25 = Instance.new("Part")
  45. Part26 = Instance.new("Part")
  46. Part27 = Instance.new("Part")
  47. Part28 = Instance.new("Part")
  48. Humanoid29 = Instance.new("Humanoid")
  49. Script30 = Instance.new("Script")
  50. Script31 = Instance.new("Script")
  51. Script32 = Instance.new("Script")
  52. BoolValue33 = Instance.new("BoolValue")
  53. Script34 = Instance.new("Script")
  54. Hat35 = Instance.new("Hat")
  55. Part36 = Instance.new("Part")
  56. SpecialMesh37 = Instance.new("SpecialMesh")
  57. Hat38 = Instance.new("Hat")
  58. Part39 = Instance.new("Part")
  59. SpecialMesh40 = Instance.new("SpecialMesh")
  60. Hat41 = Instance.new("Hat")
  61. Part42 = Instance.new("Part")
  62. SpecialMesh43 = Instance.new("SpecialMesh")
  63. Hat44 = Instance.new("Hat")
  64. Part45 = Instance.new("Part")
  65. SpecialMesh46 = Instance.new("SpecialMesh")
  66. Animation47 = Instance.new("Animation")
  67. CharacterMesh48 = Instance.new("CharacterMesh")
  68. CharacterMesh49 = Instance.new("CharacterMesh")
  69. CharacterMesh50 = Instance.new("CharacterMesh")
  70. CharacterMesh51 = Instance.new("CharacterMesh")
  71. CharacterMesh52 = Instance.new("CharacterMesh")
  72. Animation53 = Instance.new("Animation")
  73. Script54 = Instance.new("Script")
  74. Model0.Name = "SCP-049"
  75. Model0.Parent = mas
  76. Model0.PrimaryPart = Part1
  77. Part1.Name = "Head"
  78. Part1.Parent = Model0
  79. Part1.Material = Enum.Material.Fabric
  80. Part1.BrickColor = BrickColor.new("Black")
  81. Part1.Rotation = Vector3.new(0, -0.25, 0)
  82. Part1.FormFactor = Enum.FormFactor.Symmetric
  83. Part1.Friction = 0
  84. Part1.Size = Vector3.new(2, 1, 1)
  85. Part1.CFrame = CFrame.new(-38.2495918, 15.3000097, -181.684647, 0.999990344, 0, -0.00439172285, 0, 1, 0, 0.00439172285, 0, 0.999990344)
  86. Part1.TopSurface = Enum.SurfaceType.Smooth
  87. Part1.Color = Color3.new(0.105882, 0.164706, 0.207843)
  88. Part1.Position = Vector3.new(-38.2495918, 15.3000097, -181.684647)
  89. Part1.Orientation = Vector3.new(0, -0.25, 0)
  90. Part1.Color = Color3.new(0.105882, 0.164706, 0.207843)
  91. SpecialMesh2.Parent = Part1
  92. SpecialMesh2.Scale = Vector3.new(1.25, 1.25, 1.25)
  93. SpecialMesh2.Scale = Vector3.new(1.25, 1.25, 1.25)
  94. Sound3.Name = "1"
  95. Sound3.Parent = Part1
  96. Sound3.SoundId = "rbxassetid://189035323"
  97. Sound3.Volume = 1
  98. Sound4.Name = "10"
  99. Sound4.Parent = Part1
  100. Sound4.SoundId = "rbxassetid://528044348"
  101. Sound4.Volume = 1
  102. Sound5.Name = "2"
  103. Sound5.Parent = Part1
  104. Sound5.SoundId = "rbxassetid://189035381"
  105. Sound5.Volume = 1
  106. Sound6.Name = "3"
  107. Sound6.Parent = Part1
  108. Sound6.SoundId = "rbxassetid://189035450"
  109. Sound6.Volume = 1
  110. Sound7.Name = "4"
  111. Sound7.Parent = Part1
  112. Sound7.SoundId = "rbxassetid://189035504"
  113. Sound7.Volume = 1
  114. Sound8.Name = "5"
  115. Sound8.Parent = Part1
  116. Sound8.SoundId = "rbxassetid://189035671"
  117. Sound8.Volume = 1
  118. Sound9.Name = "6"
  119. Sound9.Parent = Part1
  120. Sound9.SoundId = "rbxassetid://189035728"
  121. Sound9.Volume = 1
  122. Sound10.Name = "7"
  123. Sound10.Parent = Part1
  124. Sound10.SoundId = "rbxassetid://189035763"
  125. Sound10.Volume = 1
  126. Sound11.Name = "8"
  127. Sound11.Parent = Part1
  128. Sound11.SoundId = "rbxassetid://189035803"
  129. Sound11.Volume = 1
  130. Sound12.Name = "9"
  131. Sound12.Parent = Part1
  132. Sound12.SoundId = "rbxassetid://487003745"
  133. Sound12.Volume = 1
  134. Sound13.Name = "breath"
  135. Sound13.Parent = Part1
  136. Sound13.SoundId = "rbxassetid://483810543"
  137. Sound13.Looped = true
  138. Script14.Name = "Breathingsound"
  139. Script14.Parent = Part1
  140. table.insert(cors,sandbox(Script14,function()
  141. while true do
  142. script.Parent.breath:Play()
  143. wait(28)
  144. end
  145. end))
  146. Weld15.Name = "HeadWeld"
  147. Weld15.Parent = Part1
  148. Weld15.C0 = CFrame.new(0, 0.5, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  149. Weld15.C1 = CFrame.new(0, 0.400000006, 0.639999986, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  150. Weld15.Part0 = Part1
  151. Weld15.Part1 = Part36
  152. Weld16.Name = "HeadWeld"
  153. Weld16.Parent = Part1
  154. Weld16.C0 = CFrame.new(0, 0.5, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  155. Weld16.C1 = CFrame.new(0, 0.200000003, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  156. Weld16.Part0 = Part1
  157. Weld16.Part1 = Part39
  158. Weld17.Name = "HeadWeld"
  159. Weld17.Parent = Part1
  160. Weld17.C0 = CFrame.new(0, 0.5, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  161. Weld17.C1 = CFrame.new(0.180000007, 0.449999988, 0.49000001, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  162. Weld17.Part0 = Part1
  163. Weld17.Part1 = Part42
  164. Weld18.Name = "HeadWeld"
  165. Weld18.Parent = Part1
  166. Weld18.C0 = CFrame.new(0, 0.5, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  167. Weld18.C1 = CFrame.new(-0.180000007, 0.449999988, 0.49000001, 1, -0, 0, 0, 1, -0, 0, 0, 0.99999994)
  168. Weld18.Part0 = Part1
  169. Weld18.Part1 = Part45
  170. Part19.Name = "Torso"
  171. Part19.Parent = Model0
  172. Part19.Material = Enum.Material.Fabric
  173. Part19.BrickColor = BrickColor.new("Black")
  174. Part19.Rotation = Vector3.new(0, -0.25, 0)
  175. Part19.FormFactor = Enum.FormFactor.Symmetric
  176. Part19.Friction = 0
  177. Part19.Size = Vector3.new(2, 2, 1)
  178. Part19.CFrame = CFrame.new(-38.2495918, 13.8000097, -181.684647, 0.999990344, 0, -0.00439172285, 0, 1, 0, 0.00439172285, 0, 0.999990344)
  179. Part19.LeftSurface = Enum.SurfaceType.Weld
  180. Part19.RightSurface = Enum.SurfaceType.Weld
  181. Part19.Color = Color3.new(0.105882, 0.164706, 0.207843)
  182. Part19.Position = Vector3.new(-38.2495918, 13.8000097, -181.684647)
  183. Part19.Orientation = Vector3.new(0, -0.25, 0)
  184. Part19.Color = Color3.new(0.105882, 0.164706, 0.207843)
  185. Motor20.Name = "Right Shoulder"
  186. Motor20.Parent = Part19
  187. Motor20.C0 = CFrame.new(-2, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  188. Motor20.C1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  189. Motor20.Part0 = Part26
  190. Motor20.Part1 = Part19
  191. Motor20.DesiredAngle = -0.59882825613022
  192. Motor20.MaxVelocity = 0.15000000596046
  193. Motor21.Name = "Left Shoulder"
  194. Motor21.Parent = Part19
  195. Motor21.C0 = CFrame.new(2, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  196. Motor21.C1 = CFrame.new(0.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  197. Motor21.Part0 = Part25
  198. Motor21.Part1 = Part19
  199. Motor21.DesiredAngle = -0.59882825613022
  200. Motor21.MaxVelocity = 0.15000000596046
  201. Motor22.Name = "Right Hip"
  202. Motor22.Parent = Part19
  203. Motor22.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  204. Motor22.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  205. Motor22.Part0 = Part19
  206. Motor22.Part1 = Part28
  207. Motor22.DesiredAngle = 0.14970706403255
  208. Motor22.MaxVelocity = 0.10000000149012
  209. Motor23.Name = "Left Hip"
  210. Motor23.Parent = Part19
  211. Motor23.C0 = CFrame.new(-1, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  212. Motor23.C1 = CFrame.new(-0.5, 1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  213. Motor23.Part0 = Part19
  214. Motor23.Part1 = Part27
  215. Motor23.DesiredAngle = 0.14970706403255
  216. Motor23.MaxVelocity = 0.10000000149012
  217. Motor24.Name = "Neck"
  218. Motor24.Parent = Part19
  219. Motor24.C0 = CFrame.new(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  220. Motor24.C1 = CFrame.new(0, -0.5, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  221. Motor24.Part0 = Part19
  222. Motor24.Part1 = Part1
  223. Motor24.MaxVelocity = 0.10000000149012
  224. Part25.Name = "Left Arm"
  225. Part25.Parent = Model0
  226. Part25.Material = Enum.Material.Fabric
  227. Part25.BrickColor = BrickColor.new("Black")
  228. Part25.Rotation = Vector3.new(0, -0.25, 0)
  229. Part25.CanCollide = false
  230. Part25.FormFactor = Enum.FormFactor.Symmetric
  231. Part25.Size = Vector3.new(1, 2, 1)
  232. Part25.CFrame = CFrame.new(-39.7495766, 13.8000097, -181.691238, 0.999990344, 0, -0.00439172285, 0, 1, 0, 0.00439172285, 0, 0.999990344)
  233. Part25.Color = Color3.new(0.105882, 0.164706, 0.207843)
  234. Part25.Position = Vector3.new(-39.7495766, 13.8000097, -181.691238)
  235. Part25.Orientation = Vector3.new(0, -0.25, 0)
  236. Part25.Color = Color3.new(0.105882, 0.164706, 0.207843)
  237. Part26.Name = "Right Arm"
  238. Part26.Parent = Model0
  239. Part26.Material = Enum.Material.Fabric
  240. Part26.BrickColor = BrickColor.new("Black")
  241. Part26.Rotation = Vector3.new(0, -0.25, 0)
  242. Part26.CanCollide = false
  243. Part26.FormFactor = Enum.FormFactor.Symmetric
  244. Part26.Size = Vector3.new(1, 2, 1)
  245. Part26.CFrame = CFrame.new(-36.7496071, 13.8000097, -181.678055, 0.999990344, 0, -0.00439172285, 0, 1, 0, 0.00439172285, 0, 0.999990344)
  246. Part26.Color = Color3.new(0.105882, 0.164706, 0.207843)
  247. Part26.Position = Vector3.new(-36.7496071, 13.8000097, -181.678055)
  248. Part26.Orientation = Vector3.new(0, -0.25, 0)
  249. Part26.Color = Color3.new(0.105882, 0.164706, 0.207843)
  250. Part27.Name = "Left Leg"
  251. Part27.Parent = Model0
  252. Part27.Material = Enum.Material.Fabric
  253. Part27.BrickColor = BrickColor.new("Black")
  254. Part27.Rotation = Vector3.new(0, -0.25, 0)
  255. Part27.CanCollide = false
  256. Part27.FormFactor = Enum.FormFactor.Symmetric
  257. Part27.Size = Vector3.new(1, 2, 1)
  258. Part27.CFrame = CFrame.new(-38.749588, 11.8000097, -181.686844, 0.999990344, 0, -0.00439172285, 0, 1, 0, 0.00439172285, 0, 0.999990344)
  259. Part27.BottomSurface = Enum.SurfaceType.Smooth
  260. Part27.Color = Color3.new(0.105882, 0.164706, 0.207843)
  261. Part27.Position = Vector3.new(-38.749588, 11.8000097, -181.686844)
  262. Part27.Orientation = Vector3.new(0, -0.25, 0)
  263. Part27.Color = Color3.new(0.105882, 0.164706, 0.207843)
  264. Part28.Name = "Right Leg"
  265. Part28.Parent = Model0
  266. Part28.Material = Enum.Material.Fabric
  267. Part28.BrickColor = BrickColor.new("Black")
  268. Part28.Rotation = Vector3.new(0, -0.25, 0)
  269. Part28.CanCollide = false
  270. Part28.FormFactor = Enum.FormFactor.Symmetric
  271. Part28.Size = Vector3.new(1, 2, 1)
  272. Part28.CFrame = CFrame.new(-37.7495956, 11.8000097, -181.682449, 0.999990344, 0, -0.00439172285, 0, 1, 0, 0.00439172285, 0, 0.999990344)
  273. Part28.BottomSurface = Enum.SurfaceType.Smooth
  274. Part28.Color = Color3.new(0.105882, 0.164706, 0.207843)
  275. Part28.Position = Vector3.new(-37.7495956, 11.8000097, -181.682449)
  276. Part28.Orientation = Vector3.new(0, -0.25, 0)
  277. Part28.Color = Color3.new(0.105882, 0.164706, 0.207843)
  278. Humanoid29.Name = "SCP"
  279. Humanoid29.Parent = Model0
  280. Humanoid29.NameOcclusion = Enum.NameOcclusion.NoOcclusion
  281. Humanoid29.RightLeg = Part28
  282. Humanoid29.LeftLeg = Part27
  283. Humanoid29.Torso = Part19
  284. Humanoid29.Health = 9999
  285. Humanoid29.MaxHealth = 9999
  286. Humanoid29.WalkSpeed = 10
  287. Script30.Parent = Model0
  288. table.insert(cors,sandbox(Script30,function()
  289. local larm = script.Parent:FindFirstChild("Left Arm")
  290. local rarm = script.Parent:FindFirstChild("Right Arm")
  291. sound = script.Parent.Head.Sound3
  292. function findNearestTorso(pos)
  293. local list = game.Workspace:children()
  294. local torso = nil
  295. local dist = 1000
  296. local temp = nil
  297. local human = nil
  298. local temp2 = nil
  299. for x = 1, #list do
  300. temp2 = list[x]
  301. if (temp2.className == "Model") and (temp2 ~= script.Parent) then
  302. temp = temp2:findFirstChild("Torso")
  303. human = temp2:findFirstChild("Humanoid")
  304. if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
  305. if (temp.Position - pos).magnitude < dist then
  306. torso = temp
  307. dist = (temp.Position - pos).magnitude
  308. end
  309. end
  310. end
  311. end
  312. return torso
  313. end
  314.  
  315. function Hit(hit)
  316. local human = hit.Parent:FindFirstChild("Humanoid")
  317. if human ~= nil then
  318. human.Health = human.Health -4
  319. sound:play()
  320. end
  321. end
  322.  
  323. larm.Touched:connect(Hit)
  324. rarm.Touched:connect(Hit)
  325.  
  326. while true do
  327. wait(0.1)
  328. local target = findNearestTorso(script.Parent.Torso.Position)
  329. if target ~= nil then
  330. script.Parent.Zombie:MoveTo(target.Position, target)
  331. end
  332. end
  333.  
  334. end))
  335. Script31.Name = "Respawn"
  336. Script31.Parent = Model0
  337. table.insert(cors,sandbox(Script31,function()
  338. wait(1)
  339. human = script.Parent:findFirstChild("Humanoid")
  340. if human == nil then human = script.Parent:findFirstChild("Zombie") end
  341.  
  342. if script.Parent.archivable == false then script.Parent.archivable = true end
  343. robo=script.Parent:clone()
  344. robo.Parent = game.Lighting
  345.  
  346. player = game.Players:playerFromCharacter(script.Parent)
  347. if player ~= nil then robo:findFirstChild(script.Name):remove() end
  348.  
  349. while true do
  350. wait(1)
  351. if human.Health<1 then
  352. robot=robo:clone()
  353. robot.Parent=script.Parent.Parent
  354. robot:makeJoints()
  355. wait(.1)
  356. robo:remove()
  357. script.Parent:remove()
  358. end
  359. end
  360.  
  361.  
  362.  
  363.  
  364. end))
  365. Script32.Name = "AIScript"
  366. Script32.Parent = Model0
  367. table.insert(cors,sandbox(Script32,function()
  368. --Beta SpeedAI June 2012 -- Still has logic bugs - Look for updates..
  369. -- Kill added.
  370. -- co-operate/other "AI"s
  371. -- Climb "Truss" Parts
  372. -- Offset Ray
  373. -- Swim - Does not work. Don't know why.
  374. -- Adjusted Jump Ray
  375. -- Ray Graphics On/Off - flip line 90
  376. -- Delay next cycle, if Falling.
  377. -- Diagonal movement - I should add right-hand logic as well...
  378.  
  379. local number = 1 + math.random()
  380. local BRAINWave = .6 -- AND line 38: Wait() between cycles of main loop
  381. local hum = nil -- Will be a pointer to the Humanoid of our AI.
  382.  
  383. wait(number) -- hold on a sec. and spread multiple instances.
  384.  
  385. --Globals
  386. local AI = script.Parent
  387. local AIName = AI.Name
  388. local AItorso = AI.Torso
  389.  
  390.  
  391. if true then -- if your torso doesn't have a Humanoid; flip this to false
  392. local HumanoidType = nil -- find-a-HumanoidObject -- make sure
  393.  
  394. local list = AI:GetChildren() -- temp var.
  395. for x = 1, #list do
  396. local temp = list[x]
  397. if (temp.className == "Humanoid") then
  398. HumanoidType = temp.Name
  399. end -- found Humanoid
  400. end -- AI Parts
  401.  
  402. if HumanoidType then
  403. number = math.floor(number*100) -- serial# of AI
  404. hum = AI[HumanoidType]
  405. BRAINWave = 7/hum.WalkSpeed -- For extreme speeds, this may have to be adjusted.
  406. print (script, ": Humanoid = ", hum, AI:GetFullName(), number, "- Think Speed = ", BRAINWave)
  407. end
  408. end -- set speed
  409.  
  410. --Constants;
  411. local RAYLength = 100 -- Not really. A point, off in space.
  412.  
  413. --Declarations
  414. local target = AItorso -- is of type torso
  415. local torsoPos = AItorso.Position
  416. local targpos = target.Position
  417. --local Oldtargpos = targpos
  418.  
  419. local OldPos = torsoPos * 2
  420. local origin = CFrame.new(torsoPos)
  421.  
  422. local Logic = 0
  423. local OldX = 100
  424. local OldZ = 0
  425. local Xdir = 100
  426. local Zdir = 0
  427. local ClimbingLadder = false
  428. local FreeFalling = false
  429. local GraphicsOn = script.GraphicsToggle.Value -- Only set at start
  430.  
  431. --functions
  432.  
  433. -- Are we falling?
  434. hum.FreeFalling:connect(function()
  435. FreeFalling = true
  436. end)
  437.  
  438. -- Find Player (& who else not to find).
  439. function findNearestTorso(pos) -- declare pos a local vector3
  440. local list = game.Workspace:children()
  441. local torso = nil
  442. local dist = 560 -- Area to search
  443. local temp = nil
  444. local human = nil
  445. local temp2 = nil
  446. for x = 1, #list do
  447. temp2 = list[x]
  448. if temp2.className == "Model" then
  449. temp = temp2:findFirstChild("Torso")
  450. if temp ~= nil then
  451. human = temp2:findFirstChild("Humanoid")
  452. if human ~= nil and (human.Health > 0) and (temp2.Name ~= AIName) then -- not named the same as us.
  453. if (temp.Position - pos).magnitude < dist then
  454. torso = temp
  455. dist = (temp.Position - pos).magnitude
  456. end -- closer?
  457. end -- human? Not us.
  458. end -- Has torso?
  459. end -- Model?
  460. end -- For. Loop thru parts in Workplace
  461.  
  462. return torso
  463. end -- findNearest
  464.  
  465.  
  466. function DrawRay(origin, point) -- 7 studs long
  467. local Ray = Ray.new(origin, (point).unit * 7) --Make the ray.
  468. local Hit,Position = game.Workspace:FindPartOnRay(Ray,AI) --Check for collisions along the ray, ignoring any Parts of us.
  469.  
  470. if GraphicsOn then --Graphics
  471. local RayPart = Instance.new("Part",AI)
  472. if Hit then
  473. if Logic == 1 then
  474. RayPart.BrickColor = BrickColor.new("Black") --Set its color.
  475. else
  476. RayPart.BrickColor = BrickColor.new("Bright red") --Set its color.
  477. end
  478. else
  479. if Logic == 1 then
  480. RayPart.BrickColor = BrickColor.new("White") --Set its color.
  481. else
  482. RayPart.BrickColor = BrickColor.new("Olive") --Set its color.
  483. end
  484. end
  485. RayPart.Transparency = 0.2 --Set its transparency.
  486. RayPart.Anchored = true --Set whether it will fall or not.
  487. RayPart.CanCollide = false --Set whether people can walk though it or not.
  488. RayPart.formFactor = Enum.FormFactor.Custom --Make it so it can be small.
  489. local Distance = (Position-origin).magnitude --Find the distance between the hit and the torso.
  490. RayPart.Size = Vector3.new(0.4,.2,Distance) --Set its size to the distance.
  491. RayPart.CFrame = CFrame.new(Position, origin) * CFrame.new(0,0,-Distance/2) --Move it halfway.
  492. game.Debris:AddItem(RayPart,2) --Add it to the debris.
  493. end -- Graphics
  494.  
  495. return Hit
  496. end -- DrawRay
  497.  
  498.  
  499. function FireRayToward() -- possible path, and read the Part we hit, if any.
  500. ClimbingLadder = false
  501.  
  502. local originPrime = origin * Vector3.new(.8,0,0) - Vector3.new(0,.4,0) -- Offset Right + OffY
  503. local offset = origin * Vector3.new(.8,0,0) - origin * Vector3.new(-.8,0,0) -- left (I guess this is increment. I didn't WANT to do it this way)
  504. local point = origin.lookVector * 7 -- dir
  505. local pointPrime = point - offset + Vector3.new(0,2,0) -- dir + OffsetLeft + OffsetY = direction of Ray
  506.  
  507. local Hit = DrawRay(originPrime, pointPrime) -- see if we hit anything
  508.  
  509. if Hit then
  510.  
  511. if target.Parent == Hit.Parent then
  512. -- AI.Head:BreakJoints()
  513. if Hit.Name ~= "Head" and Hit.Name ~= "Torso" then
  514.  
  515. else
  516. Hit.Parent.Humanoid:TakeDamage(100)
  517. end -- kill
  518.  
  519. Logic = 0
  520. Hit = nil
  521.  
  522. elseif Hit.Parent.Name == AIName then
  523. -- if Xdir > 0 then -- if going ?North? then ignore, else (?South?); Jump
  524. -- Hit = nil -- ignore
  525. -- elseif Xdir == 0 then -- else swerve (only while in logic).
  526. if Xdir == 0 then
  527. Hit = Aitorso-- this should result in Hit = true-but-don't-attemp-a-jump, so swerve; doesn't check floor!
  528. -- return hit -- Swerve, without checking to jump.
  529. elseif Hit.Velocity.y > 1 then
  530. Hit = nil -- ignore, if other AI is already jumping; else check to Jump
  531. end -- East -West collisions - swerve. North/South, check-to-jump.
  532. end -- endifs
  533. end -- read hit
  534.  
  535. -- Climb or Jump
  536. if Hit and Hit ~= AItorso then
  537.  
  538. if (Hit.Name == "Truss" and target.Position.y > torsoPos.y - 3) or target.Parent == Hit.Parent then -- ignore parts called "Ladder", if AI is level or below CURRENT Targ pos.
  539. Hit = nil
  540. ClimbingLadder = true -- Climb and don't check floor
  541.  
  542. else
  543. --print(Hit, Hit.Name)
  544. if Hit.Name == "Terrain" or Hit.CanCollide == false then -- In front is Water or a steep hill made of Terrain.
  545. Hit = nil -- swim or climb, or Ray hit a Non-colliding Part; and don't check for floor. This will not do, as we do not get a Hit when under-water, so we will check for floor. We must check Swimming event.
  546. else -- Jump?
  547. Hit = DrawRay(originPrime + Vector3.new(0,4.8,0), pointPrime)
  548. if Hit == nil then -- (Does NOT check CanCollide of Part blocking Jump)
  549. hum.Jump = true -- we do NOT check for "Floor", if jumping, but it might be a good idea.
  550. end -- Room to jump?
  551. end --Terrain? Water?
  552. end -- Ladder?
  553.  
  554. else -- path is clear. Check for cliff... or OK to drop
  555.  
  556. local Level = torsoPos.y
  557. if target then
  558. Level = target.Position.y -- get Target's current position.
  559. else -- Target is dead. Abandon all logic...
  560. Logic = 0 -- but still check for floor
  561. end
  562.  
  563. if torsoPos.y - 2 < Level then -- if Player is not well below us...
  564.  
  565. Hit = DrawRay(torsoPos + point * .8 + Vector3.new(0,1,0), Vector3.new(0,-7,0)) -- check for floor 85% of dir ahead
  566. if Hit == nil then -- There is no floor
  567. Hit = true -- Force a hit; we may not be able to get back up here.
  568.  
  569. else
  570. Hit = nil -- Force a false to hit, 'cause everything is OK. (Does NOT check CanCollide of Floor!)
  571. end -- cliff check
  572. end -- Player Hieght
  573. end -- path ok?
  574. return Hit
  575. end -- FireRayToward
  576.  
  577.  
  578. function FireAtPlayer()
  579. origin = CFrame.new(torsoPos, Vector3.new(targpos.x, torsoPos.y, targpos.z)) -- This contains Origin & Direction
  580. local hit = FireRayToward()
  581. return hit
  582. end
  583.  
  584. function FireRayAhead()
  585. origin = CFrame.new(torsoPos, torsoPos + Vector3.new(Xdir, 0, Zdir))
  586. local hit = FireRayToward()
  587. targpos = torsoPos + Vector3.new(Xdir,0,Zdir)
  588. return hit
  589. end
  590.  
  591. function FireRay() -- Fire Ahead and diagonaly
  592. origin = CFrame.new(torsoPos, torsoPos + Vector3.new(Xdag, 0, Zdag))
  593. local hit = FireRayToward()
  594. if hit then
  595. origin = CFrame.new(torsoPos, torsoPos + Vector3.new(Xdir, 0, Zdir))
  596. hit = FireRayToward()
  597. if not hit then
  598. targpos = torsoPos + Vector3.new(Xdir,0,Zdir)
  599. end
  600. else
  601. targpos = torsoPos + Vector3.new(Xdag,0,Zdag)
  602. end
  603. return hit
  604. end -- Fire Ray
  605.  
  606. function FireDag()
  607. origin = CFrame.new(torsoPos, torsoPos + Vector3.new(Xdag, 0, Zdag))
  608. local hit = FireRayToward()
  609. return hit
  610. end -- Fire Diagonaly
  611.  
  612.  
  613. function TurnRight()
  614.  
  615. if Xdir == 0 then
  616. Xdir = -Zdir
  617. Zdir = 0
  618. else
  619. Zdir = Xdir
  620. Xdir = 0
  621. end
  622. if Xdag == Zdag then Xdag = -Xdag else Zdag = -Zdag end
  623.  
  624. end -- Left
  625.  
  626. function TurnLeft()
  627. if Xdir == 0 then
  628. Xdir = Zdir
  629. Zdir = 0
  630. else
  631. Zdir = -Xdir
  632. Xdir = 0
  633. end
  634.  
  635. if Xdag == Zdag then Zdag = -Zdag else Xdag = -Xdag end
  636.  
  637. end -- Left
  638.  
  639.  
  640. function GetDir()
  641. Xdir = (targpos.x - torsoPos.x) -- Which way are we going?
  642. Zdir = (targpos.z - torsoPos.z)
  643.  
  644. -- if Zdir < 0 then -- Get closest 45 degree angle. Diagonal.
  645. -- Zdag = -RAYLength
  646. -- else
  647. -- Zdag = RAYLength
  648. -- end
  649. -- if Xdir < 0 then
  650. -- Xdag = -RAYLength
  651. -- else
  652. -- Xdag = RAYLength
  653. -- end
  654.  
  655. if math.abs(Xdir) > math.abs(Zdir) then -- Ordinal.
  656. if Xdir < 0 then
  657. Xdir = -RAYLength
  658. -- convert to our direction indicator.
  659. else
  660. Xdir = RAYLength
  661. end
  662. Zdag = Xdir -- Diagonal Right.
  663. Xdag = Xdir
  664. Zdir = 0
  665. else -- abs
  666. if Zdir < 0 then
  667. Zdir = -RAYLength
  668. else
  669. Zdir = RAYLength
  670. end
  671. Zdag = Zdir
  672. Xdag = -Zdir
  673. Xdir = 0
  674. end -- abs
  675. end -- GetDir
  676.  
  677.  
  678. while AItorso do -- while I still have a body; search.
  679. torsoPos = AItorso.Position
  680. local targ = Workspace.Terrain -- Temp targ
  681. local Distance =(torsoPos - OldPos).magnitude -- Distance traveled, since last loop
  682. --local Distance =10
  683. if target == nil then Logic = 0
  684. -- Distance = 10
  685. end -- Player died.
  686.  
  687.  
  688. if Logic == 0 then -- Defalt logic
  689.  
  690. target = findNearestTorso(torsoPos) --- target is some Player. FindNearest and get xdir, ydir.
  691.  
  692. if target ~= nil then
  693. targ = target
  694. -- if ClimbingLadder and Distance >= 1 then
  695. -- targpos = torsoPos + AItorso.CFrame.lookVector * 9
  696. -- else
  697. targpos = target.Position
  698. -- end
  699.  
  700. if Distance < 1 and (torsoPos - targpos).magnitude > 4 then -- Check if we are stuck.
  701. GetDir()
  702. OldX = Xdir -- Goal direction.
  703. OldZ = Zdir
  704.  
  705. Logic = 1 -- Impeded
  706.  
  707. else
  708. if FireAtPlayer() then -- hit
  709.  
  710. GetDir()
  711. OldX = Xdir -- Goal direction.
  712. OldZ = Zdir
  713.  
  714. if FireDag() then
  715. Logic = 1 -- Go Left; Look Right.
  716. ClimbingLadder = true -- first time thru logic 1 indicator
  717. else
  718. targpos = torsoPos + Vector3.new(Xdag,0,Zdag) -- go Right
  719.  
  720. end -- dagRight
  721. end -- hit?
  722. end -- impeded?
  723. else
  724. print(AIName, number, ": No target. - ", target)
  725. -- torsoPos = torsoPos * 2 -- Turn Impeded?, off
  726. -- Distance = 10
  727. end -- if no target?
  728. end -- Logic 0
  729.  
  730.  
  731. -- 1 - Look Right or Go left
  732. if Logic == 1 then
  733.  
  734. if Distance >= 1 then
  735. if ClimbingLadder == false then -- or target.Position.y < torsoPos.y + 4 then
  736. TurnRight()
  737. end -- else go straight or go up
  738. else
  739. TurnLeft()
  740. end
  741.  
  742. if FireRayAhead() then -- Check straight first. (And Diagonaly left)
  743. TurnLeft()
  744. if FireRay() then -- Check left (And Diagonaly left & back)
  745. TurnLeft()
  746. if FireRay() then
  747. TurnLeft()
  748. if FireRay() then
  749. targpos = torsoPos + Vector3.new(Xdir,0,Zdir)
  750. hum.Jump = true
  751. end -- right
  752. end -- Back
  753. end -- Left
  754. else -- If succesful Ahead then... (We only check RightTurns for a get-out-of-jail-Free card)
  755.  
  756. if Xdir == OldX and OldZ == Zdir then -- Gracefully exiting Logic 1
  757. Logic = 0
  758. end -- check Goal dir?
  759. end -- Ahead
  760. end -- Logic 1
  761.  
  762. -- go
  763. OldPos = torsoPos
  764. hum:MoveTo(targpos, targ) -- MoveToward Target
  765.  
  766. --wait
  767. wait(BRAINWave)
  768.  
  769. while FreeFalling do
  770. FreeFalling = false
  771. wait(.2)
  772. end
  773.  
  774. end -- Main
  775.  
  776. end))
  777. BoolValue33.Name = "GraphicsToggle"
  778. BoolValue33.Parent = Script32
  779. Script34.Name = "SCP049HeadSoundScript"
  780. Script34.Parent = Model0
  781. table.insert(cors,sandbox(Script34,function()
  782. --[[ By: Brutez ]]--
  783. local SCP049 = script.Parent;
  784. local SCP049Head = SCP049:FindFirstChild("Head");
  785. local SelectedSoundID = {187645728, 187645755, 187645778};
  786. local SelectedSounds = {};
  787. local HurtEnable = true;
  788. while true do
  789. Wait(0)
  790. SCP049RandomSound=math.random(1,1000)
  791. if SCP049RandomSound==10 or SCP049RandomSound==20 or SCP049RandomSound==30 then
  792. if HurtEnable==false then return end
  793. HurtEnable = false;
  794. local SCP049HurtSoundList = {"049_1", "049_2", "049_3", "049_4", "049_5", "049_6", "049_7", "049_8", "049_9","049_10"};
  795. local SelectedHurtSound = SCP049Head[math.random(1, #SCP049HurtSoundList)];
  796. SelectedHurtSound:Play()
  797. Wait(4)
  798. HurtEnable = true;
  799. end
  800. end
  801.  
  802. end))
  803. Hat35.Name = "Mask"
  804. Hat35.Parent = Model0
  805. Hat35.AttachmentPos = Vector3.new(0, 0.400000006, 0.639999986)
  806. Part36.Name = "Handle"
  807. Part36.Parent = Hat35
  808. Part36.Material = Enum.Material.Fabric
  809. Part36.BrickColor = BrickColor.new("Black")
  810. Part36.Rotation = Vector3.new(0, -0.25, 0)
  811. Part36.CanCollide = false
  812. Part36.FormFactor = Enum.FormFactor.Symmetric
  813. Part36.Size = Vector3.new(1, 1, 2)
  814. Part36.CFrame = CFrame.new(-38.2467804, 15.4000101, -182.324646, 0.999990344, 0, -0.00439172285, 0, 1, 0, 0.00439172285, 0, 0.999990344)
  815. Part36.BottomSurface = Enum.SurfaceType.Smooth
  816. Part36.TopSurface = Enum.SurfaceType.Smooth
  817. Part36.Color = Color3.new(0.105882, 0.164706, 0.207843)
  818. Part36.Position = Vector3.new(-38.2467804, 15.4000101, -182.324646)
  819. Part36.Orientation = Vector3.new(0, -0.25, 0)
  820. Part36.Color = Color3.new(0.105882, 0.164706, 0.207843)
  821. SpecialMesh37.Parent = Part36
  822. SpecialMesh37.MeshId = "http://www.roblox.com/asset/?id=12472639"
  823. SpecialMesh37.Scale = Vector3.new(1.20000005, 1.20000005, 1.5)
  824. SpecialMesh37.TextureId = "http://www.roblox.com/asset/?id=189029251"
  825. SpecialMesh37.MeshType = Enum.MeshType.FileMesh
  826. SpecialMesh37.Scale = Vector3.new(1.20000005, 1.20000005, 1.5)
  827. Hat38.Name = "Hood"
  828. Hat38.Parent = Model0
  829. Hat38.AttachmentPos = Vector3.new(0, 0.200000003, 0)
  830. Part39.Name = "Handle"
  831. Part39.Parent = Hat38
  832. Part39.Material = Enum.Material.Fabric
  833. Part39.BrickColor = BrickColor.new("Black")
  834. Part39.Rotation = Vector3.new(0, -0.25, 0)
  835. Part39.CanCollide = false
  836. Part39.FormFactor = Enum.FormFactor.Symmetric
  837. Part39.Size = Vector3.new(1, 1, 2)
  838. Part39.CFrame = CFrame.new(-38.2495918, 15.6000099, -181.684647, 0.999990344, 0, -0.00439172285, 0, 1, 0, 0.00439172285, 0, 0.999990344)
  839. Part39.BottomSurface = Enum.SurfaceType.Smooth
  840. Part39.TopSurface = Enum.SurfaceType.Smooth
  841. Part39.Color = Color3.new(0.105882, 0.164706, 0.207843)
  842. Part39.Position = Vector3.new(-38.2495918, 15.6000099, -181.684647)
  843. Part39.Orientation = Vector3.new(0, -0.25, 0)
  844. Part39.Color = Color3.new(0.105882, 0.164706, 0.207843)
  845. SpecialMesh40.Parent = Part39
  846. SpecialMesh40.MeshId = "http://www.roblox.com/asset/?id=16952952"
  847. SpecialMesh40.Scale = Vector3.new(1, 1.14999998, 1.29999995)
  848. SpecialMesh40.TextureId = "http://www.roblox.com/asset/?id=189029867"
  849. SpecialMesh40.MeshType = Enum.MeshType.FileMesh
  850. SpecialMesh40.Scale = Vector3.new(1, 1.14999998, 1.29999995)
  851. Hat41.Name = "Eye"
  852. Hat41.Parent = Model0
  853. Hat41.AttachmentPos = Vector3.new(0.180000007, 0.449999988, 0.49000001)
  854. Part42.Name = "Handle"
  855. Part42.Parent = Hat41
  856. Part42.Material = Enum.Material.Fabric
  857. Part42.BrickColor = BrickColor.new("Black")
  858. Part42.Rotation = Vector3.new(0, -0.25, 0)
  859. Part42.CanCollide = false
  860. Part42.FormFactor = Enum.FormFactor.Custom
  861. Part42.Size = Vector3.new(0.5, 0.5, 0.5)
  862. Part42.CFrame = CFrame.new(-38.4274368, 15.3500099, -182.17543, 0.999990344, 0, -0.00439172285, 0, 1, 0, 0.00439172285, 0, 0.999990344)
  863. Part42.BottomSurface = Enum.SurfaceType.Smooth
  864. Part42.TopSurface = Enum.SurfaceType.Smooth
  865. Part42.Color = Color3.new(0.105882, 0.164706, 0.207843)
  866. Part42.Position = Vector3.new(-38.4274368, 15.3500099, -182.17543)
  867. Part42.Orientation = Vector3.new(0, -0.25, 0)
  868. Part42.Color = Color3.new(0.105882, 0.164706, 0.207843)
  869. SpecialMesh43.Parent = Part42
  870. SpecialMesh43.MeshId = "http://www.roblox.com/asset/?id=1185246"
  871. SpecialMesh43.Scale = Vector3.new(0.300000012, 0.300000012, 0.300000012)
  872. SpecialMesh43.TextureId = "http://www.roblox.com/asset/?id=189023804"
  873. SpecialMesh43.MeshType = Enum.MeshType.FileMesh
  874. SpecialMesh43.Scale = Vector3.new(0.300000012, 0.300000012, 0.300000012)
  875. Hat44.Name = "Eye"
  876. Hat44.Parent = Model0
  877. Hat44.AttachmentForward = Vector3.new(-0, 0, -0.99999994)
  878. Hat44.AttachmentPos = Vector3.new(-0.180000007, 0.449999988, 0.49000001)
  879. Part45.Name = "Handle"
  880. Part45.Parent = Hat44
  881. Part45.Material = Enum.Material.Fabric
  882. Part45.BrickColor = BrickColor.new("Black")
  883. Part45.Rotation = Vector3.new(0, -0.25, 0)
  884. Part45.CanCollide = false
  885. Part45.FormFactor = Enum.FormFactor.Custom
  886. Part45.Size = Vector3.new(0.5, 0.5, 0.5)
  887. Part45.CFrame = CFrame.new(-38.06744, 15.3500099, -182.173859, 0.999990344, 0, -0.00439172238, 0, 1, 0, 0.00439172285, 0, 0.999990284)
  888. Part45.BottomSurface = Enum.SurfaceType.Smooth
  889. Part45.TopSurface = Enum.SurfaceType.Smooth
  890. Part45.Color = Color3.new(0.105882, 0.164706, 0.207843)
  891. Part45.Position = Vector3.new(-38.06744, 15.3500099, -182.173859)
  892. Part45.Orientation = Vector3.new(0, -0.25, 0)
  893. Part45.Color = Color3.new(0.105882, 0.164706, 0.207843)
  894. SpecialMesh46.Parent = Part45
  895. SpecialMesh46.MeshId = "http://www.roblox.com/asset/?id=1185246"
  896. SpecialMesh46.Scale = Vector3.new(0.300000012, 0.300000012, 0.300000012)
  897. SpecialMesh46.TextureId = "http://www.roblox.com/asset/?id=189023804"
  898. SpecialMesh46.MeshType = Enum.MeshType.FileMesh
  899. SpecialMesh46.Scale = Vector3.new(0.300000012, 0.300000012, 0.300000012)
  900. Animation47.Name = "ArmOutAnim"
  901. Animation47.Parent = Model0
  902. Animation47.AnimationId = "rbxassetid://89134792"
  903. CharacterMesh48.Name = "Pilgrim Left Arm"
  904. CharacterMesh48.Parent = Model0
  905. CharacterMesh48.MeshId = 66229897
  906. CharacterMesh48.BodyPart = Enum.BodyPart.LeftArm
  907. CharacterMesh48.OverlayTextureId = 189033450
  908. CharacterMesh49.Name = "Pilgrim Right Arm"
  909. CharacterMesh49.Parent = Model0
  910. CharacterMesh49.MeshId = 66229924
  911. CharacterMesh49.BodyPart = Enum.BodyPart.RightArm
  912. CharacterMesh49.OverlayTextureId = 189033450
  913. CharacterMesh50.Name = "Pilgrim Torso"
  914. CharacterMesh50.Parent = Model0
  915. CharacterMesh50.MeshId = 66230010
  916. CharacterMesh50.BodyPart = Enum.BodyPart.Torso
  917. CharacterMesh50.OverlayTextureId = 189033450
  918. CharacterMesh51.Name = "WAI Left Leg"
  919. CharacterMesh51.Parent = Model0
  920. CharacterMesh51.MeshId = 106703213
  921. CharacterMesh51.BodyPart = Enum.BodyPart.LeftLeg
  922. CharacterMesh51.OverlayTextureId = 189033450
  923. CharacterMesh52.Name = "WAI RightLeg"
  924. CharacterMesh52.Parent = Model0
  925. CharacterMesh52.MeshId = 106703301
  926. CharacterMesh52.BodyPart = Enum.BodyPart.RightLeg
  927. CharacterMesh52.OverlayTextureId = 189033450
  928. Animation53.Name = "WalkAnim"
  929. Animation53.Parent = Model0
  930. Animation53.AnimationId = "rbxassetid://180426354"
  931. Script54.Name = "AnimateAny"
  932. Script54.Parent = Model0
  933. table.insert(cors,sandbox(Script54,function()
  934. -- Enemy by RangeMeludE --
  935.  
  936. function waitForChild(parent, childName)
  937. while true do
  938. local child = parent:findFirstChild(childName)
  939. if child then
  940. return child
  941. end
  942. parent.ChildAdded:wait()
  943. end
  944. end
  945.  
  946.  
  947. ----------------------------- TEAM COLORS
  948.  
  949.  
  950. ----------------------------- ANIMATION
  951.  
  952. -- declarations
  953.  
  954. local Figure = script.Parent
  955. local Torso = waitForChild(Figure, "Torso")
  956. local RightShoulder = waitForChild(Torso, "Right Shoulder")
  957. local LeftShoulder = waitForChild(Torso, "Left Shoulder")
  958. local RightHip = waitForChild(Torso, "Right Hip")
  959. local LeftHip = waitForChild(Torso, "Left Hip")
  960. local Neck = waitForChild(Torso, "Neck")
  961.  
  962. local Humanoid = nil -- Hack to Animate a Humanoid, no mateer what Humanoid is .Named.
  963. if true then
  964. local list = Figure:GetChildren() -- temp var.
  965. for x = 1, #list do
  966. local temp = list[x]
  967. if (temp.className == "Humanoid") then
  968. Humanoid = temp.Name
  969. end -- found Humanoid
  970. end -- Parts
  971. end -- Discard list
  972. local Humanoid = Figure[Humanoid]
  973.  
  974. --local Humanoid = waitForChild(Figure, "Humanoid")
  975.  
  976. local pose = "Standing"
  977.  
  978. local toolAnim = "None"
  979. local toolAnimTime = 0
  980.  
  981. local isSeated = false
  982.  
  983. -- functions
  984.  
  985. function onRunning(speed)
  986. if isSeated then return end
  987.  
  988. if speed>0 then
  989. pose = "Running"
  990. else
  991. pose = "Standing"
  992. end
  993. end
  994.  
  995. function onDied()
  996. pose = "Dead"
  997. end
  998.  
  999. function onJumping()
  1000. isSeated = false
  1001. pose = "Jumping"
  1002. end
  1003.  
  1004. function onClimbing()
  1005. pose = "Climbing"
  1006. end
  1007.  
  1008. function onGettingUp()
  1009. pose = "GettingUp"
  1010. end
  1011.  
  1012. function onFreeFall()
  1013. pose = "FreeFall"
  1014. end
  1015.  
  1016. function onFallingDown()
  1017. pose = "FallingDown"
  1018. end
  1019.  
  1020. function onSeated()
  1021. isSeated = true
  1022. pose = "Seated"
  1023. print("Seated")
  1024. end
  1025.  
  1026.  
  1027.  
  1028. function moveJump()
  1029. RightShoulder.MaxVelocity = 0.5
  1030. LeftShoulder.MaxVelocity = 0.5
  1031. RightShoulder.DesiredAngle = 3.14
  1032. LeftShoulder.DesiredAngle = -3.14
  1033. RightHip.DesiredAngle = 0
  1034. LeftHip.DesiredAngle = 0
  1035. end
  1036.  
  1037. function moveFreeFall()
  1038. RightShoulder.MaxVelocity = 0.5
  1039. LeftShoulder.MaxVelocity = 0.5
  1040. RightShoulder.DesiredAngle = 1
  1041. LeftShoulder.DesiredAngle = -1
  1042. RightHip.DesiredAngle = 0
  1043. LeftHip.DesiredAngle = 0
  1044. end
  1045.  
  1046.  
  1047. function moveClimb()
  1048. RightShoulder.MaxVelocity = 0.5
  1049. LeftShoulder.MaxVelocity = 0.5
  1050. RightShoulder.DesiredAngle = -3.14
  1051. LeftShoulder.DesiredAngle = 3.14
  1052. RightHip.DesiredAngle = 0
  1053. LeftHip.DesiredAngle = 0
  1054. end
  1055.  
  1056. function moveSit()
  1057. print("Move Sit")
  1058. RightShoulder.MaxVelocity = 0.15
  1059. LeftShoulder.MaxVelocity = 0.15
  1060. RightShoulder.DesiredAngle = 3.14 /2
  1061. LeftShoulder.DesiredAngle = -3.14 /2
  1062. RightHip.DesiredAngle = 3.14 /2
  1063. LeftHip.DesiredAngle = -3.14 /2
  1064. end
  1065.  
  1066. function getTool()
  1067.  
  1068. kidTable = Figure:children()
  1069. if (kidTable ~= nil) then
  1070. numKids = #kidTable
  1071. for i=1,numKids do
  1072. if (kidTable[i].className == "Tool") then return kidTable[i] end
  1073. end
  1074. end
  1075.  
  1076. return nil
  1077. end
  1078.  
  1079. function getToolAnim(tool)
  1080.  
  1081. c = tool:children()
  1082. for i=1,#c do
  1083. if (c[i].Name == "toolanim" and c[i].className == "StringValue") then
  1084. return c[i]
  1085. end
  1086. end
  1087. return nil
  1088. end
  1089.  
  1090. function animateTool()
  1091.  
  1092. if (toolAnim == "None") then
  1093. RightShoulder.DesiredAngle = 1.57
  1094. return
  1095. end
  1096.  
  1097. if (toolAnim == "Slash") then
  1098. RightShoulder.MaxVelocity = 0.5
  1099. RightShoulder.DesiredAngle = 0
  1100. return
  1101. end
  1102.  
  1103. if (toolAnim == "Lunge") then
  1104. RightShoulder.MaxVelocity = 0.5
  1105. LeftShoulder.MaxVelocity = 0.5
  1106. RightHip.MaxVelocity = 0.5
  1107. LeftHip.MaxVelocity = 0.5
  1108. RightShoulder.DesiredAngle = 1.57
  1109. LeftShoulder.DesiredAngle = 1.0
  1110. RightHip.DesiredAngle = 1.57
  1111. LeftHip.DesiredAngle = 1.0
  1112. return
  1113. end
  1114. end
  1115.  
  1116. function move(time)
  1117. local amplitude
  1118. local frequency
  1119.  
  1120. if (pose == "Jumping") then
  1121. moveJump()
  1122. return
  1123. end
  1124.  
  1125. if (pose == "FreeFall") then
  1126. moveFreeFall()
  1127. return
  1128. end
  1129.  
  1130. if (pose == "Climbing") then
  1131. moveClimb()
  1132. return
  1133. end
  1134.  
  1135. if (pose == "Seated") then
  1136. moveSit()
  1137. return
  1138. end
  1139.  
  1140.  
  1141. RightShoulder.MaxVelocity = 0.15
  1142. LeftShoulder.MaxVelocity = 0.15
  1143. if (pose == "Running") then
  1144. amplitude = 1
  1145. frequency = 9
  1146. else
  1147. amplitude = 0.1
  1148. frequency = 1
  1149. end
  1150.  
  1151. desiredAngle = amplitude * math.sin(time*frequency)
  1152.  
  1153. RightShoulder.DesiredAngle = desiredAngle
  1154. LeftShoulder.DesiredAngle = desiredAngle
  1155. RightHip.DesiredAngle = -desiredAngle/4
  1156. LeftHip.DesiredAngle = -desiredAngle/4
  1157.  
  1158.  
  1159. local tool = getTool()
  1160.  
  1161. if tool ~= nil then
  1162.  
  1163. animStringValueObject = getToolAnim(tool)
  1164.  
  1165. if animStringValueObject ~= nil then
  1166. toolAnim = animStringValueObject.Value
  1167. -- message recieved, delete StringValue
  1168. animStringValueObject.Parent = nil
  1169. toolAnimTime = time + .3
  1170. end
  1171.  
  1172. if time > toolAnimTime then
  1173. toolAnimTime = 0
  1174. toolAnim = "None"
  1175. end
  1176.  
  1177. animateTool()
  1178.  
  1179.  
  1180. else
  1181. toolAnim = "None"
  1182. toolAnimTime = 0
  1183. end
  1184. end
  1185.  
  1186.  
  1187. -- connect events
  1188.  
  1189. Humanoid.Died:connect(onDied)
  1190. Humanoid.Running:connect(onRunning)
  1191. Humanoid.Jumping:connect(onJumping)
  1192. Humanoid.Climbing:connect(onClimbing)
  1193. Humanoid.GettingUp:connect(onGettingUp)
  1194. Humanoid.FreeFalling:connect(onFreeFall)
  1195. Humanoid.FallingDown:connect(onFallingDown)
  1196. Humanoid.Seated:connect(onSeated)
  1197.  
  1198. -- main program
  1199.  
  1200. local nextTime = 0
  1201. local runService = game:service("RunService");
  1202.  
  1203. while Figure.Parent~=nil do
  1204. time = runService.Stepped:wait()
  1205. if time > nextTime then
  1206. move(time)
  1207. nextTime = time + .1
  1208. end
  1209. end
  1210.  
  1211. end))
  1212. for i,v in pairs(mas:GetChildren()) do
  1213. v.Parent = workspace
  1214. pcall(function() v:MakeJoints() end)
  1215. end
  1216. mas:Destroy()
  1217. for i,v in pairs(cors) do
  1218. spawn(function()
  1219. pcall(v)
  1220. end)
  1221. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement