Advertisement
memberhero

test4

Nov 20th, 2017
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 58.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. Sound2 = Instance.new("Sound")
  22. Sound3 = Instance.new("Sound")
  23. Sound4 = Instance.new("Sound")
  24. Decal5 = Instance.new("Decal")
  25. SpecialMesh6 = Instance.new("SpecialMesh")
  26. Weld7 = Instance.new("Weld")
  27. Part8 = Instance.new("Part")
  28. Decal9 = Instance.new("Decal")
  29. Motor6D10 = Instance.new("Motor6D")
  30. Motor6D11 = Instance.new("Motor6D")
  31. Motor6D12 = Instance.new("Motor6D")
  32. Motor6D13 = Instance.new("Motor6D")
  33. Motor6D14 = Instance.new("Motor6D")
  34. Part15 = Instance.new("Part")
  35. Part16 = Instance.new("Part")
  36. Part17 = Instance.new("Part")
  37. Part18 = Instance.new("Part")
  38. Humanoid19 = Instance.new("Humanoid")
  39. Part20 = Instance.new("Part")
  40. Motor6D21 = Instance.new("Motor6D")
  41. Script22 = Instance.new("Script")
  42. BodyColors23 = Instance.new("BodyColors")
  43. Script24 = Instance.new("Script")
  44. StringValue25 = Instance.new("StringValue")
  45. Animation26 = Instance.new("Animation")
  46. StringValue27 = Instance.new("StringValue")
  47. Animation28 = Instance.new("Animation")
  48. StringValue29 = Instance.new("StringValue")
  49. Animation30 = Instance.new("Animation")
  50. NumberValue31 = Instance.new("NumberValue")
  51. Animation32 = Instance.new("Animation")
  52. NumberValue33 = Instance.new("NumberValue")
  53. StringValue34 = Instance.new("StringValue")
  54. Animation35 = Instance.new("Animation")
  55. StringValue36 = Instance.new("StringValue")
  56. Animation37 = Instance.new("Animation")
  57. StringValue38 = Instance.new("StringValue")
  58. Animation39 = Instance.new("Animation")
  59. StringValue40 = Instance.new("StringValue")
  60. Animation41 = Instance.new("Animation")
  61. StringValue42 = Instance.new("StringValue")
  62. Animation43 = Instance.new("Animation")
  63. Sound44 = Instance.new("Sound")
  64. Script45 = Instance.new("Script")
  65. Animation46 = Instance.new("Animation")
  66. CharacterMesh47 = Instance.new("CharacterMesh")
  67. CharacterMesh48 = Instance.new("CharacterMesh")
  68. CharacterMesh49 = Instance.new("CharacterMesh")
  69. CharacterMesh50 = Instance.new("CharacterMesh")
  70. CharacterMesh51 = Instance.new("CharacterMesh")
  71. Shirt52 = Instance.new("Shirt")
  72. Pants53 = Instance.new("Pants")
  73. Hat54 = Instance.new("Hat")
  74. Part55 = Instance.new("Part")
  75. SpecialMesh56 = Instance.new("SpecialMesh")
  76. Script57 = Instance.new("Script")
  77. Animation58 = Instance.new("Animation")
  78. BindableFunction59 = Instance.new("BindableFunction")
  79. BindableEvent60 = Instance.new("BindableEvent")
  80. BindableEvent61 = Instance.new("BindableEvent")
  81. BindableEvent62 = Instance.new("BindableEvent")
  82. Configuration63 = Instance.new("Configuration")
  83. ObjectValue64 = Instance.new("ObjectValue")
  84. Configuration65 = Instance.new("Configuration")
  85. NumberValue66 = Instance.new("NumberValue")
  86. BoolValue67 = Instance.new("BoolValue")
  87. BoolValue68 = Instance.new("BoolValue")
  88. Vector3Value69 = Instance.new("Vector3Value")
  89. BoolValue70 = Instance.new("BoolValue")
  90. BrickColorValue71 = Instance.new("BrickColorValue")
  91. NumberValue72 = Instance.new("NumberValue")
  92. NumberValue73 = Instance.new("NumberValue")
  93. NumberValue74 = Instance.new("NumberValue")
  94. Model0.Name = "DrTrayBlox"
  95. Model0.Parent = mas
  96. Part1.Name = "Head"
  97. Part1.Parent = Model0
  98. Part1.BrickColor = BrickColor.new("Pastel brown")
  99. Part1.Rotation = Vector3.new(0, -57.8199997, 0)
  100. Part1.Velocity = Vector3.new(1.40129846e-45, 0, 1.40129846e-45)
  101. Part1.Locked = true
  102. Part1.FormFactor = Enum.FormFactor.Symmetric
  103. Part1.Size = Vector3.new(2, 1, 1)
  104. Part1.CFrame = CFrame.new(20.9954529, 4.50000906, 7.42480421, 0.53263253, 0, -0.846346557, 0, 1, 0, 0.846346557, 0, 0.53263253)
  105. Part1.TopSurface = Enum.SurfaceType.Smooth
  106. Part1.Color = Color3.new(1, 0.8, 0.6)
  107. Part1.Position = Vector3.new(20.9954529, 4.50000906, 7.42480421)
  108. Part1.Orientation = Vector3.new(0, -57.8199997, 0)
  109. Part1.Color = Color3.new(1, 0.8, 0.6)
  110. Sound2.Name = "StomedyHit"
  111. Sound2.Parent = Part1
  112. Sound2.Pitch = 1.5
  113. Sound2.SoundId = "rbxassetid://386946017"
  114. Sound2.Volume = 1
  115. Sound3.Name = "StomedyMain"
  116. Sound3.Parent = Part1
  117. Sound3.Volume = 1
  118. Sound3.Looped = true
  119. Sound4.Name = "StomedyStep"
  120. Sound4.Parent = Part1
  121. Sound4.Pitch = 2.0999999046326
  122. Sound4.SoundId = "rbxassetid://379611235"
  123. Sound4.Volume = 1
  124. Decal5.Name = "face"
  125. Decal5.Parent = Part1
  126. Decal5.Texture = "rbxasset://textures/face.png"
  127. SpecialMesh6.Parent = Part1
  128. SpecialMesh6.MeshId = "http://www.roblox.com/asset/?id=83001675"
  129. SpecialMesh6.Scale = Vector3.new(1.25, 1.25, 1.25)
  130. SpecialMesh6.MeshType = Enum.MeshType.FileMesh
  131. SpecialMesh6.Scale = Vector3.new(1.25, 1.25, 1.25)
  132. Weld7.Name = "HeadWeld"
  133. Weld7.Parent = Part1
  134. Weld7.C0 = CFrame.new(0, 0.5, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  135. Weld7.C1 = CFrame.new(0, 0.200000003, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  136. Weld7.Part0 = Part1
  137. Weld7.Part1 = Part55
  138. Part8.Name = "Torso"
  139. Part8.Parent = Model0
  140. Part8.BrickColor = BrickColor.new("White")
  141. Part8.Rotation = Vector3.new(0, -57.8199997, 0)
  142. Part8.Velocity = Vector3.new(1.40129846e-45, 0, 1.40129846e-45)
  143. Part8.Locked = true
  144. Part8.FormFactor = Enum.FormFactor.Symmetric
  145. Part8.Size = Vector3.new(2, 2, 1)
  146. Part8.CFrame = CFrame.new(20.9954529, 3.00000906, 7.42480421, 0.53263253, 0, -0.846346557, 0, 1, 0, 0.846346557, 0, 0.53263253)
  147. Part8.LeftSurface = Enum.SurfaceType.Weld
  148. Part8.RightSurface = Enum.SurfaceType.Weld
  149. Part8.Color = Color3.new(0.94902, 0.952941, 0.952941)
  150. Part8.Position = Vector3.new(20.9954529, 3.00000906, 7.42480421)
  151. Part8.Orientation = Vector3.new(0, -57.8199997, 0)
  152. Part8.Color = Color3.new(0.94902, 0.952941, 0.952941)
  153. Decal9.Name = "roblox"
  154. Decal9.Parent = Part8
  155. Motor6D10.Name = "Right Shoulder"
  156. Motor6D10.Parent = Part8
  157. Motor6D10.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  158. Motor6D10.C1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  159. Motor6D10.Part0 = Part8
  160. Motor6D10.Part1 = Part16
  161. Motor6D10.MaxVelocity = 0.10000000149012
  162. Motor6D11.Name = "Left Shoulder"
  163. Motor6D11.Parent = Part8
  164. Motor6D11.C0 = CFrame.new(-1, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  165. Motor6D11.C1 = CFrame.new(0.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  166. Motor6D11.Part0 = Part8
  167. Motor6D11.Part1 = Part15
  168. Motor6D11.MaxVelocity = 0.10000000149012
  169. Motor6D12.Name = "Right Hip"
  170. Motor6D12.Parent = Part8
  171. Motor6D12.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  172. Motor6D12.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  173. Motor6D12.Part0 = Part8
  174. Motor6D12.Part1 = Part18
  175. Motor6D12.MaxVelocity = 0.10000000149012
  176. Motor6D13.Name = "Left Hip"
  177. Motor6D13.Parent = Part8
  178. Motor6D13.C0 = CFrame.new(-1, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  179. Motor6D13.C1 = CFrame.new(-0.5, 1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  180. Motor6D13.Part0 = Part8
  181. Motor6D13.Part1 = Part17
  182. Motor6D13.MaxVelocity = 0.10000000149012
  183. Motor6D14.Name = "Neck"
  184. Motor6D14.Parent = Part8
  185. Motor6D14.C0 = CFrame.new(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  186. Motor6D14.C1 = CFrame.new(0, -0.5, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  187. Motor6D14.Part0 = Part8
  188. Motor6D14.Part1 = Part1
  189. Motor6D14.MaxVelocity = 0.10000000149012
  190. Part15.Name = "Left Arm"
  191. Part15.Parent = Model0
  192. Part15.BrickColor = BrickColor.new("Pastel brown")
  193. Part15.Rotation = Vector3.new(0, -57.8199997, 0)
  194. Part15.Velocity = Vector3.new(1.40129846e-45, 0, 1.40129846e-45)
  195. Part15.CanCollide = false
  196. Part15.Locked = true
  197. Part15.FormFactor = Enum.FormFactor.Symmetric
  198. Part15.Size = Vector3.new(1, 2, 1)
  199. Part15.CFrame = CFrame.new(20.1965046, 3.00000906, 6.1552844, 0.53263253, 0, -0.846346557, 0, 1, 0, 0.846346557, 0, 0.53263253)
  200. Part15.Color = Color3.new(1, 0.8, 0.6)
  201. Part15.Position = Vector3.new(20.1965046, 3.00000906, 6.1552844)
  202. Part15.Orientation = Vector3.new(0, -57.8199997, 0)
  203. Part15.Color = Color3.new(1, 0.8, 0.6)
  204. Part16.Name = "Right Arm"
  205. Part16.Parent = Model0
  206. Part16.BrickColor = BrickColor.new("Pastel brown")
  207. Part16.Rotation = Vector3.new(0, -57.8199997, 0)
  208. Part16.Velocity = Vector3.new(1.40129846e-45, 0, 1.40129846e-45)
  209. Part16.CanCollide = false
  210. Part16.Locked = true
  211. Part16.FormFactor = Enum.FormFactor.Symmetric
  212. Part16.Size = Vector3.new(1, 2, 1)
  213. Part16.CFrame = CFrame.new(21.7944012, 3.00000906, 8.69432449, 0.53263253, 0, -0.846346557, 0, 1, 0, 0.846346557, 0, 0.53263253)
  214. Part16.Color = Color3.new(1, 0.8, 0.6)
  215. Part16.Position = Vector3.new(21.7944012, 3.00000906, 8.69432449)
  216. Part16.Orientation = Vector3.new(0, -57.8199997, 0)
  217. Part16.Color = Color3.new(1, 0.8, 0.6)
  218. Part17.Name = "Left Leg"
  219. Part17.Parent = Model0
  220. Part17.BrickColor = BrickColor.new("Medium blue")
  221. Part17.Rotation = Vector3.new(0, -57.8199997, 0)
  222. Part17.Velocity = Vector3.new(1.40129846e-45, 0, 1.40129846e-45)
  223. Part17.CanCollide = false
  224. Part17.Locked = true
  225. Part17.FormFactor = Enum.FormFactor.Symmetric
  226. Part17.Size = Vector3.new(1, 2, 1)
  227. Part17.CFrame = CFrame.new(20.7291374, 1.00000906, 7.00163078, 0.53263253, 0, -0.846346557, 0, 1, 0, 0.846346557, 0, 0.53263253)
  228. Part17.BottomSurface = Enum.SurfaceType.Smooth
  229. Part17.Color = Color3.new(0.431373, 0.6, 0.792157)
  230. Part17.Position = Vector3.new(20.7291374, 1.00000906, 7.00163078)
  231. Part17.Orientation = Vector3.new(0, -57.8199997, 0)
  232. Part17.Color = Color3.new(0.431373, 0.6, 0.792157)
  233. Part18.Name = "Right Leg"
  234. Part18.Parent = Model0
  235. Part18.BrickColor = BrickColor.new("Medium blue")
  236. Part18.Rotation = Vector3.new(0, -57.8199997, 0)
  237. Part18.Velocity = Vector3.new(1.40129846e-45, 0, 1.40129846e-45)
  238. Part18.CanCollide = false
  239. Part18.Locked = true
  240. Part18.FormFactor = Enum.FormFactor.Symmetric
  241. Part18.Size = Vector3.new(1, 2, 1)
  242. Part18.CFrame = CFrame.new(21.2617683, 1.00000906, 7.84797764, 0.53263253, 0, -0.846346557, 0, 1, 0, 0.846346557, 0, 0.53263253)
  243. Part18.BottomSurface = Enum.SurfaceType.Smooth
  244. Part18.Color = Color3.new(0.431373, 0.6, 0.792157)
  245. Part18.Position = Vector3.new(21.2617683, 1.00000906, 7.84797764)
  246. Part18.Orientation = Vector3.new(0, -57.8199997, 0)
  247. Part18.Color = Color3.new(0.431373, 0.6, 0.792157)
  248. Humanoid19.Parent = Model0
  249. Humanoid19.RightLeg = Part18
  250. Humanoid19.LeftLeg = Part17
  251. Humanoid19.Torso = Part20
  252. Part20.Name = "HumanoidRootPart"
  253. Part20.Parent = Model0
  254. Part20.Transparency = 1
  255. Part20.Rotation = Vector3.new(0, -57.8199997, 0)
  256. Part20.Velocity = Vector3.new(1.40129846e-45, 0, 1.40129846e-45)
  257. Part20.CanCollide = false
  258. Part20.Locked = true
  259. Part20.FormFactor = Enum.FormFactor.Symmetric
  260. Part20.Size = Vector3.new(2, 2, 1)
  261. Part20.CFrame = CFrame.new(20.9954529, 3.00000906, 7.42480421, 0.53263253, 0, -0.846346557, 0, 1, 0, 0.846346557, 0, 0.53263253)
  262. Part20.BottomSurface = Enum.SurfaceType.Smooth
  263. Part20.TopSurface = Enum.SurfaceType.Smooth
  264. Part20.Position = Vector3.new(20.9954529, 3.00000906, 7.42480421)
  265. Part20.Orientation = Vector3.new(0, -57.8199997, 0)
  266. Motor6D21.Name = "RootJoint"
  267. Motor6D21.Parent = Part20
  268. Motor6D21.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  269. Motor6D21.C1 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  270. Motor6D21.Part0 = Part20
  271. Motor6D21.Part1 = Part8
  272. Motor6D21.MaxVelocity = 0.10000000149012
  273. Script22.Name = "Health"
  274. Script22.Parent = Model0
  275. table.insert(cors,sandbox(Script22,function()
  276. --Responsible for regening a player's humanoid's health
  277.  
  278. -- declarations
  279. local Figure = script.Parent
  280. local Head = Figure:WaitForChild("Head")
  281. local Humanoid = Figure:WaitForChild("Humanoid")
  282. local regening = false
  283.  
  284. -- regeneration
  285. function regenHealth()
  286. if regening then return end
  287. regening = true
  288.  
  289. while Humanoid.Health < Humanoid.MaxHealth do
  290. local s = wait(1)
  291. local health = Humanoid.Health
  292. if health > 0 and health < Humanoid.MaxHealth then
  293. local newHealthDelta = 250 * s * Humanoid.MaxHealth
  294. health = health + newHealthDelta
  295. Humanoid.Health = math.min(health,Humanoid.MaxHealth)
  296. end
  297. end
  298.  
  299. if Humanoid.Health > Humanoid.MaxHealth then
  300. Humanoid.Health = Humanoid.MaxHealth
  301. end
  302.  
  303. regening = false
  304. end
  305.  
  306. Humanoid.HealthChanged:connect(regenHealth)
  307.  
  308. end))
  309. BodyColors23.Parent = Model0
  310. BodyColors23.HeadColor = BrickColor.new("Pastel brown")
  311. BodyColors23.LeftArmColor = BrickColor.new("Pastel brown")
  312. BodyColors23.LeftLegColor = BrickColor.new("Medium blue")
  313. BodyColors23.RightArmColor = BrickColor.new("Pastel brown")
  314. BodyColors23.RightLegColor = BrickColor.new("Medium blue")
  315. BodyColors23.TorsoColor = BrickColor.new("White")
  316. Script24.Name = "AnimateSauce"
  317. Script24.Parent = Model0
  318. table.insert(cors,sandbox(Script24,function()
  319. function waitForChild(parent, childName)
  320. local child = parent:findFirstChild(childName)
  321. if child then return child end
  322. while true do
  323. child = parent.ChildAdded:wait()
  324. if child.Name==childName then return child end
  325. end
  326. end
  327. local Figure = script.Parent
  328. local Torso = waitForChild(Figure, "Torso")
  329. local RightShoulder = waitForChild(Torso, "Right Shoulder")
  330. local LeftShoulder = waitForChild(Torso, "Left Shoulder")
  331. local RightHip = waitForChild(Torso, "Right Hip")
  332. local LeftHip = waitForChild(Torso, "Left Hip")
  333. local Neck = waitForChild(Torso, "Neck")
  334. local Humanoid;
  335. for _,Child in pairs(Figure:GetChildren())do
  336. if Child and Child.ClassName=="Humanoid"then
  337. Humanoid=Child;
  338. end;
  339. end;
  340. local pose = "Standing"
  341. local currentAnim = ""
  342. local currentAnimInstance = nil
  343. local currentAnimTrack = nil
  344. local currentAnimKeyframeHandler = nil
  345. local currentAnimSpeed = 1.0
  346. local animTable = {}
  347. local animNames = {
  348. idle = {
  349. { id = "http://www.roblox.com/asset/?id=180435571", weight = 9 },
  350. { id = "http://www.roblox.com/asset/?id=180435792", weight = 1 }
  351. },
  352. walk = {
  353. { id = "http://www.roblox.com/asset/?id=180426354", weight = 10 }
  354. },
  355. run = {
  356. { id = "http://www.roblox.com/asset/?id=252557606", weight = 20 }
  357. },
  358. jump = {
  359. { id = "http://www.roblox.com/asset/?id=125750702", weight = 10 }
  360. },
  361. fall = {
  362. { id = "http://www.roblox.com/asset/?id=180436148", weight = 10 }
  363. },
  364. climb = {
  365. { id = "http://www.roblox.com/asset/?id=180436334", weight = 10 }
  366. },
  367. sit = {
  368. { id = "http://www.roblox.com/asset/?id=178130996", weight = 10 }
  369. },
  370. toolnone = {
  371. { id = "http://www.roblox.com/asset/?id=182393478", weight = 10 }
  372. },
  373. toolslash = {
  374. { id = "http://www.roblox.com/asset/?id=129967390", weight = 10 }
  375. --{ id = "slash.xml", weight = 10 }
  376. },
  377. toollunge = {
  378. { id = "http://www.roblox.com/asset/?id=129967478", weight = 10 }
  379. },
  380. wave = {
  381. { id = "http://www.roblox.com/asset/?id=128777973", weight = 10 }
  382. },
  383. point = {
  384. { id = "http://www.roblox.com/asset/?id=128853357", weight = 10 }
  385. },
  386. dance1 = {
  387. { id = "http://www.roblox.com/asset/?id=182435998", weight = 10 },
  388. { id = "http://www.roblox.com/asset/?id=182491037", weight = 10 },
  389. { id = "http://www.roblox.com/asset/?id=182491065", weight = 10 }
  390. },
  391. dance2 = {
  392. { id = "http://www.roblox.com/asset/?id=182436842", weight = 10 },
  393. { id = "http://www.roblox.com/asset/?id=182491248", weight = 10 },
  394. { id = "http://www.roblox.com/asset/?id=182491277", weight = 10 }
  395. },
  396. dance3 = {
  397. { id = "http://www.roblox.com/asset/?id=182436935", weight = 10 },
  398. { id = "http://www.roblox.com/asset/?id=182491368", weight = 10 },
  399. { id = "http://www.roblox.com/asset/?id=182491423", weight = 10 }
  400. },
  401. laugh = {
  402. { id = "http://www.roblox.com/asset/?id=129423131", weight = 10 }
  403. },
  404. cheer = {
  405. { id = "http://www.roblox.com/asset/?id=129423030", weight = 10 }
  406. },
  407. }
  408. local dances = {"dance1", "dance2", "dance3"}
  409.  
  410. -- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote
  411. local emoteNames = { wave = false, point = false, dance1 = true, dance2 = true, dance3 = true, laugh = false, cheer = false}
  412.  
  413. function configureAnimationSet(name, fileList)
  414. if (animTable[name] ~= nil) then
  415. for _, connection in pairs(animTable[name].connections) do
  416. connection:disconnect()
  417. end
  418. end
  419. animTable[name] = {}
  420. animTable[name].count = 0
  421. animTable[name].totalWeight = 0
  422. animTable[name].connections = {}
  423.  
  424. -- check for config values
  425. local config = script:FindFirstChild(name)
  426. if (config ~= nil) then
  427. --print("Loading anims " .. name)
  428. table.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))
  429. table.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))
  430. local idx = 1
  431. for _, childPart in pairs(config:GetChildren()) do
  432. if (childPart:IsA("Animation")) then
  433. table.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))
  434. animTable[name][idx] = {}
  435. animTable[name][idx].anim = childPart
  436. local weightObject = childPart:FindFirstChild("Weight")
  437. if (weightObject == nil) then
  438. animTable[name][idx].weight = 1
  439. else
  440. animTable[name][idx].weight = weightObject.Value
  441. end
  442. animTable[name].count = animTable[name].count + 1
  443. animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
  444. --print(name .. " [" .. idx .. "] " .. animTable[name][idx].anim.AnimationId .. " (" .. animTable[name][idx].weight .. ")")
  445. idx = idx + 1
  446. end
  447. end
  448. end
  449.  
  450. -- fallback to defaults
  451. if (animTable[name].count <= 0) then
  452. for idx, anim in pairs(fileList) do
  453. animTable[name][idx] = {}
  454. animTable[name][idx].anim = Instance.new("Animation")
  455. animTable[name][idx].anim.Name = name
  456. animTable[name][idx].anim.AnimationId = anim.id
  457. animTable[name][idx].weight = anim.weight
  458. animTable[name].count = animTable[name].count + 1
  459. animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
  460. --print(name .. " [" .. idx .. "] " .. anim.id .. " (" .. anim.weight .. ")")
  461. end
  462. end
  463. end
  464.  
  465. -- Setup animation objects
  466. function scriptChildModified(child)
  467. local fileList = animNames[child.Name]
  468. if (fileList ~= nil) then
  469. configureAnimationSet(child.Name, fileList)
  470. end
  471. end
  472.  
  473. script.ChildAdded:connect(scriptChildModified)
  474. script.ChildRemoved:connect(scriptChildModified)
  475.  
  476.  
  477. for name, fileList in pairs(animNames) do
  478. configureAnimationSet(name, fileList)
  479. end
  480.  
  481. -- ANIMATION
  482.  
  483. -- declarations
  484. local toolAnim = "None"
  485. local toolAnimTime = 0
  486.  
  487. local jumpAnimTime = 0
  488. local jumpAnimDuration = 0.3
  489.  
  490. local toolTransitionTime = 0.1
  491. local fallTransitionTime = 0.3
  492. local jumpMaxLimbVelocity = 0.75
  493.  
  494. -- functions
  495.  
  496. function stopAllAnimations()
  497. local oldAnim = currentAnim
  498.  
  499. -- return to idle if finishing an emote
  500. if (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then
  501. oldAnim = "idle"
  502. end
  503.  
  504. currentAnim = ""
  505. currentAnimInstance = nil
  506. if (currentAnimKeyframeHandler ~= nil) then
  507. currentAnimKeyframeHandler:disconnect()
  508. end
  509.  
  510. if (currentAnimTrack ~= nil) then
  511. currentAnimTrack:Stop()
  512. currentAnimTrack:Destroy()
  513. currentAnimTrack = nil
  514. end
  515. return oldAnim
  516. end
  517.  
  518. function setAnimationSpeed(speed)
  519. if speed ~= currentAnimSpeed then
  520. currentAnimSpeed = speed
  521. currentAnimTrack:AdjustSpeed(currentAnimSpeed)
  522. end
  523. end
  524.  
  525. function keyFrameReachedFunc(frameName)
  526. if (frameName == "End") then
  527.  
  528. local repeatAnim = currentAnim
  529. -- return to idle if finishing an emote
  530. if (emoteNames[repeatAnim] ~= nil and emoteNames[repeatAnim] == false) then
  531. repeatAnim = "idle"
  532. end
  533.  
  534. local animSpeed = currentAnimSpeed
  535. playAnimation(repeatAnim, 0.0, Humanoid)
  536. setAnimationSpeed(animSpeed)
  537. end
  538. end
  539.  
  540. -- Preload animations
  541. function playAnimation(animName, transitionTime, humanoid)
  542.  
  543. local roll = math.random(1, animTable[animName].totalWeight)
  544. local origRoll = roll
  545. local idx = 1
  546. while (roll > animTable[animName][idx].weight) do
  547. roll = roll - animTable[animName][idx].weight
  548. idx = idx + 1
  549. end
  550. --print(animName .. " " .. idx .. " [" .. origRoll .. "]")
  551. local anim = animTable[animName][idx].anim
  552. -- switch animation
  553. if (anim ~= currentAnimInstance) then
  554. if (currentAnimTrack ~= nil) then
  555. currentAnimTrack:Stop(transitionTime)
  556. currentAnimTrack:Destroy()
  557. end
  558. currentAnimSpeed = 1.0
  559. -- load it to the humanoid; get AnimationTrack
  560. currentAnimTrack = humanoid:LoadAnimation(anim)
  561. -- play the animation
  562. currentAnimTrack:Play(transitionTime)
  563. currentAnim = animName
  564. currentAnimInstance = anim
  565. -- set up keyframe name triggers
  566. if (currentAnimKeyframeHandler ~= nil) then
  567. currentAnimKeyframeHandler:disconnect()
  568. end
  569. currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
  570. end
  571. end
  572. -------------------------------------------------------------------------------------------
  573. -------------------------------------------------------------------------------------------
  574. local toolAnimName = ""
  575. local toolAnimTrack = nil
  576. local toolAnimInstance = nil
  577. local currentToolAnimKeyframeHandler = nil
  578. function toolKeyFrameReachedFunc(frameName)
  579. if (frameName == "End") then
  580. --print("Keyframe : ".. frameName)
  581. playToolAnimation(toolAnimName, 0.0, Humanoid)
  582. end
  583. end
  584. function playToolAnimation(animName, transitionTime, humanoid)
  585. local roll = math.random(1, animTable[animName].totalWeight)
  586. local origRoll = roll
  587. local idx = 1
  588. while (roll > animTable[animName][idx].weight) do
  589. roll = roll - animTable[animName][idx].weight
  590. idx = idx + 1
  591. end
  592. --print(animName .. " * " .. idx .. " [" .. origRoll .. "]")
  593. local anim = animTable[animName][idx].anim
  594. if (toolAnimInstance ~= anim) then
  595. if (toolAnimTrack ~= nil) then
  596. toolAnimTrack:Stop()
  597. toolAnimTrack:Destroy()
  598. transitionTime = 0
  599. end
  600. -- load it to the humanoid; get AnimationTrack
  601. toolAnimTrack = humanoid:LoadAnimation(anim)
  602. -- play the animation
  603. toolAnimTrack:Play(transitionTime)
  604. toolAnimName = animName
  605. toolAnimInstance = anim
  606. currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
  607. end
  608. end
  609. function stopToolAnimations()
  610. local oldAnim = toolAnimName
  611. if (currentToolAnimKeyframeHandler ~= nil) then
  612. currentToolAnimKeyframeHandler:disconnect()
  613. end
  614. toolAnimName = ""
  615. toolAnimInstance = nil
  616. if (toolAnimTrack ~= nil) then
  617. toolAnimTrack:Stop()
  618. toolAnimTrack:Destroy()
  619. toolAnimTrack = nil
  620. end
  621. return oldAnim
  622. end
  623. -------------------------------------------------------------------------------------------
  624. -------------------------------------------------------------------------------------------
  625. function onRunning(speed)
  626. if speed>0.01 then
  627. if Figure and Humanoid and Humanoid.WalkSpeed<17 then
  628. playAnimation("walk", 0.1, Humanoid);
  629. elseif Figure and Humanoid and Humanoid.WalkSpeed>17 then
  630. playAnimation("run", 0.1, Humanoid);
  631. end;
  632. if currentAnimInstance and currentAnimInstance.AnimationId == "http://www.roblox.com/asset/?id=180426354" then
  633. setAnimationSpeed(speed / 14.5)
  634. end
  635. pose = "Running"
  636. else
  637. playAnimation("idle", 0.1, Humanoid)
  638. pose = "Standing"
  639. end
  640. end
  641. function onDied()
  642. pose = "Dead"
  643. end
  644. function onJumping()
  645. playAnimation("jump", 0.1, Humanoid)
  646. jumpAnimTime = jumpAnimDuration
  647. pose = "Jumping"
  648. end
  649. function onClimbing(speed)
  650. playAnimation("climb", 0.1, Humanoid)
  651. setAnimationSpeed(speed / 12.0)
  652. pose = "Climbing"
  653. end
  654. function onGettingUp()
  655. pose = "GettingUp"
  656. end
  657. function onFreeFall()
  658. if (jumpAnimTime <= 0) then
  659. playAnimation("fall", fallTransitionTime, Humanoid)
  660. end
  661. pose = "FreeFall"
  662. end
  663. function onFallingDown()
  664. pose = "FallingDown"
  665. end
  666. function onSeated()
  667. pose = "Seated"
  668. end
  669. function onPlatformStanding()
  670. pose = "PlatformStanding"
  671. end
  672. function onSwimming(speed)
  673. if speed>0 then
  674. pose = "Running"
  675. else
  676. pose = "Standing"
  677. end
  678. end
  679.  
  680. function getTool()
  681. for _, kid in ipairs(Figure:GetChildren()) do
  682. if kid.className == "Tool" then return kid end
  683. end
  684. return nil
  685. end
  686.  
  687. function getToolAnim(tool)
  688. for _, c in ipairs(tool:GetChildren()) do
  689. if c.Name == "toolanim" and c.className == "StringValue" then
  690. return c
  691. end
  692. end
  693. return nil
  694. end
  695.  
  696. function animateTool()
  697.  
  698. if (toolAnim == "None") then
  699. playToolAnimation("toolnone", toolTransitionTime, Humanoid)
  700. return
  701. end
  702.  
  703. if (toolAnim == "Slash") then
  704. playToolAnimation("toolslash", 0, Humanoid)
  705. return
  706. end
  707.  
  708. if (toolAnim == "Lunge") then
  709. playToolAnimation("toollunge", 0, Humanoid)
  710. return
  711. end
  712. end
  713.  
  714. function moveSit()
  715. RightShoulder.MaxVelocity = 0.15
  716. LeftShoulder.MaxVelocity = 0.15
  717. RightShoulder:SetDesiredAngle(3.14 /2)
  718. LeftShoulder:SetDesiredAngle(-3.14 /2)
  719. RightHip:SetDesiredAngle(3.14 /2)
  720. LeftHip:SetDesiredAngle(-3.14 /2)
  721. end
  722.  
  723. local lastTick = 0
  724.  
  725. function move(time)
  726. local amplitude = 1
  727. local frequency = 1
  728. local deltaTime = time - lastTick
  729. lastTick = time
  730.  
  731. local climbFudge = 0
  732. local setAngles = false
  733.  
  734. if (jumpAnimTime > 0) then
  735. jumpAnimTime = jumpAnimTime - deltaTime
  736. end
  737.  
  738. if (pose == "FreeFall" and jumpAnimTime <= 0) then
  739. playAnimation("fall", fallTransitionTime, Humanoid)
  740. elseif (pose == "Seated") then
  741. playAnimation("sit", 0.5, Humanoid)
  742. return
  743. elseif (pose == "Running") then
  744. if Figure and Humanoid and Humanoid.WalkSpeed<17 then
  745. playAnimation("walk", 0.1, Humanoid);
  746. elseif Figure and Humanoid and Humanoid.WalkSpeed>17 then
  747. playAnimation("run", 0.1, Humanoid);
  748. end;
  749. elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then
  750. stopAllAnimations()
  751. amplitude = 0.1
  752. frequency = 1
  753. setAngles = true
  754. end
  755. if (setAngles) then
  756. local desiredAngle = amplitude * math.sin(time * frequency)
  757. RightShoulder:SetDesiredAngle(desiredAngle + climbFudge)
  758. LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
  759. RightHip:SetDesiredAngle(-desiredAngle)
  760. LeftHip:SetDesiredAngle(-desiredAngle)
  761. end
  762. -- Tool Animation handling
  763. local tool = getTool()
  764. if tool and tool:FindFirstChild("Handle") then
  765. local animStringValueObject = getToolAnim(tool)
  766. if animStringValueObject then
  767. toolAnim = animStringValueObject.Value
  768. -- message recieved, delete StringValue
  769. animStringValueObject.Parent = nil
  770. toolAnimTime = time + .3
  771. end
  772. if time > toolAnimTime then
  773. toolAnimTime = 0
  774. toolAnim = "None"
  775. end
  776. animateTool()
  777. else
  778. stopToolAnimations()
  779. toolAnim = "None"
  780. toolAnimInstance = nil
  781. toolAnimTime = 0
  782. end
  783. end
  784. -- connect events
  785. Humanoid.Died:connect(onDied)
  786. Humanoid.Running:connect(onRunning)
  787. Humanoid.Jumping:connect(onJumping)
  788. Humanoid.Climbing:connect(onClimbing)
  789. Humanoid.GettingUp:connect(onGettingUp)
  790. Humanoid.FreeFalling:connect(onFreeFall)
  791. Humanoid.FallingDown:connect(onFallingDown)
  792. Humanoid.Seated:connect(onSeated)
  793. Humanoid.PlatformStanding:connect(onPlatformStanding)
  794. Humanoid.Swimming:connect(onSwimming)
  795. local runService = game:GetService("RunService");
  796. playAnimation("idle", 0.1, Humanoid)
  797. pose = "Standing"
  798. while Wait(0)do
  799. local _,time=wait(0)
  800. move(time)
  801. end
  802. end))
  803. StringValue25.Name = "climb"
  804. StringValue25.Parent = Script24
  805. Animation26.Name = "ClimbAnim"
  806. Animation26.Parent = StringValue25
  807. Animation26.AnimationId = "http://www.roblox.com/asset/?id=180436334"
  808. StringValue27.Name = "fall"
  809. StringValue27.Parent = Script24
  810. Animation28.Name = "FallAnim"
  811. Animation28.Parent = StringValue27
  812. Animation28.AnimationId = "http://www.roblox.com/asset/?id=180436148"
  813. StringValue29.Name = "idle"
  814. StringValue29.Parent = Script24
  815. Animation30.Name = "Animation1"
  816. Animation30.Parent = StringValue29
  817. Animation30.AnimationId = "http://www.roblox.com/asset/?id=180435571"
  818. NumberValue31.Name = "Weight"
  819. NumberValue31.Parent = Animation30
  820. NumberValue31.Value = 9
  821. Animation32.Name = "Animation2"
  822. Animation32.Parent = StringValue29
  823. Animation32.AnimationId = "http://www.roblox.com/asset/?id=180435792"
  824. NumberValue33.Name = "Weight"
  825. NumberValue33.Parent = Animation32
  826. NumberValue33.Value = 1
  827. StringValue34.Name = "jump"
  828. StringValue34.Parent = Script24
  829. Animation35.Name = "JumpAnim"
  830. Animation35.Parent = StringValue34
  831. Animation35.AnimationId = "http://www.roblox.com/asset/?id=125750702"
  832. StringValue36.Name = "run"
  833. StringValue36.Parent = Script24
  834. Animation37.Name = "RunAnim"
  835. Animation37.Parent = StringValue36
  836. Animation37.AnimationId = "http://www.roblox.com/asset/?id=252557606"
  837. StringValue38.Name = "sit"
  838. StringValue38.Parent = Script24
  839. Animation39.Name = "SitAnim"
  840. Animation39.Parent = StringValue38
  841. Animation39.AnimationId = "http://www.roblox.com/asset/?id=178130996"
  842. StringValue40.Name = "toolnone"
  843. StringValue40.Parent = Script24
  844. Animation41.Name = "ToolNoneAnim"
  845. Animation41.Parent = StringValue40
  846. Animation41.AnimationId = "http://www.roblox.com/asset/?id=182393478"
  847. StringValue42.Name = "walk"
  848. StringValue42.Parent = Script24
  849. Animation43.Name = "WalkAnim"
  850. Animation43.Parent = StringValue42
  851. Animation43.AnimationId = "http://www.roblox.com/asset/?id=180426354"
  852. Sound44.Name = "Cardboard"
  853. Sound44.Parent = Model0
  854. Sound44.SoundId = "rbxassetid://409476963"
  855. Sound44.Volume = 1
  856. Sound44.Looped = true
  857. Script45.Name = "StomedyMain"
  858. Script45.Parent = Model0
  859. table.insert(cors,sandbox(Script45,function()
  860. --[[ By: Brutez. ]]--
  861. local StomedyScript=script;
  862. repeat Wait(0)until StomedyScript and StomedyScript.Parent and StomedyScript.Parent:IsA("Model")and StomedyScript.Parent:FindFirstChild("Head")and StomedyScript.Parent:FindFirstChild("Torso");
  863. local Stomedy=StomedyScript.Parent;
  864. function raycast(Spos,vec,currentdist)
  865. local hit2,pos2=game.Workspace:FindPartOnRay(Ray.new(Spos+(vec*.05),vec*currentdist),Stomedy);
  866. if hit2~=nil and pos2 then
  867. if hit2.Name=="Handle" and not hit2.CanCollide or string.sub(hit2.Name,1,6)=="Effect"and not hit2.CanCollide then
  868. local currentdist=currentdist-(pos2-Spos).magnitude;
  869. return raycast(pos2,vec,currentdist);
  870. end;
  871. end;
  872. return hit2,pos2;
  873. end;
  874. function RayCast(Position,Direction,MaxDistance,IgnoreList)
  875. return Game:GetService("Workspace"):FindPartOnRayWithIgnoreList(Ray.new(Position,Direction.unit*(MaxDistance or 999.999)),IgnoreList);
  876. end;
  877. local StomedyHumanoid;
  878. for _,Child in pairs(Stomedy:GetChildren())do
  879. if Child~=nil and Child:IsA("Humanoid")and Child.Health~=0 then
  880. StomedyHumanoid=Child;
  881. end;
  882. end;
  883. local AttackDebounce=false;
  884. local StomedyHead=Stomedy:FindFirstChild("Head");
  885. local StomedyHumanoidRootPart=Stomedy:FindFirstChild("HumanoidRootPart");
  886. local WalkDebounce=false;
  887. local DynamicWander=true;
  888. local MusicDebounce=false;
  889. local OriginalC0;
  890. if StomedyScript~=nil and Stomedy~=nil and Stomedy:FindFirstChild("Torso")and Stomedy:FindFirstChild("Torso"):FindFirstChild("Neck")then
  891. Stomedy:FindFirstChild("Torso"):FindFirstChild("Neck").C0=CFrame.new(0,1,0,-1,0,0,0,0,1,0,1,-0);
  892. OriginalC0=Stomedy:FindFirstChild("Torso"):FindFirstChild("Neck").C0;
  893. end;
  894. function FindNearestBae()
  895. local NoticeDistance=200;
  896. local TargetMain;
  897. for _,TargetModel in pairs(Game:GetService("Workspace"):GetChildren())do
  898. if StomedyScript and Stomedy and StomedyHumanoid and StomedyHumanoid.Health~=0 and TargetModel:IsA("Model")and TargetModel~=Stomedy and TargetModel.Name~=Stomedy.Name and TargetModel:FindFirstChild("Torso")and TargetModel:FindFirstChild("Head")then
  899. local TargetPart=TargetModel:FindFirstChild("Torso");
  900. local FoundHumanoid;
  901. for _,Child in pairs(TargetModel:GetChildren())do
  902. if Child~=nil and Child:IsA("Humanoid")and Child.Health~=0 then
  903. FoundHumanoid=Child;
  904. end;
  905. end;
  906. if TargetModel~=nil and TargetPart~=nil and FoundHumanoid~=nil and FoundHumanoid.Health~=0 and(TargetPart.Position-StomedyHumanoidRootPart.Position).magnitude<NoticeDistance then
  907. TargetMain=TargetPart;
  908. NoticeDistance=(TargetPart.Position-StomedyHumanoidRootPart.Position).magnitude;
  909. end;
  910. end;
  911. end;
  912. return TargetMain;
  913. end;
  914. while Wait(0)do
  915. if StomedyScript~=nil and Stomedy~=nil and StomedyHead~=nil and StomedyHead:FindFirstChild("StomedyMain")and not StomedyHead:FindFirstChild("StomedyMain").IsPlaying then
  916. StomedyHead:FindFirstChild("StomedyMain"):Play();
  917. end;
  918. local TargetPoint=StomedyHumanoid.TargetPoint;
  919. local Blockage,BlockagePos=RayCast((StomedyHumanoidRootPart.CFrame+CFrame.new(StomedyHumanoidRootPart.Position,Vector3.new(TargetPoint.X,StomedyHumanoidRootPart.Position.Y,TargetPoint.Z)).lookVector*(StomedyHumanoidRootPart.Size.Z/2)).p,StomedyHumanoidRootPart.CFrame.lookVector,(StomedyHumanoidRootPart.Size.Z*2.5),{Stomedy,Stomedy})
  920. local Jumpable=false;
  921. local MainTarget=FindNearestBae();
  922. local BlockageHumanoid;
  923. if Blockage~=nil then
  924. if Blockage~=nil and Blockage.Parent~=nil and Blockage.Parent:IsA("Model")then
  925. for _,Child in pairs(Blockage.Parent:GetChildren())do
  926. if Child~=nil and Child:IsA("Humanoid")and Child.Health~=0 then
  927. BlockageHumanoid=Child;
  928. end;
  929. end;
  930. end;
  931. Jumpable=true;
  932. if Blockage and Blockage:IsA("Terrain")then
  933. local CellPos=Blockage:WorldToCellPreferSolid((BlockagePos-Vector3.new(0,2,0)));
  934. local CellMaterial,CellShape,CellOrientation=Blockage:GetCell(CellPos.X,CellPos.Y,CellPos.Z);
  935. if CellMaterial==Enum.CellMaterial.Water or MainTarget and Blockage:IsDescendantOf(MainTarget.Parent)or BlockageHumanoid~=nil then
  936. Jumpable=false;
  937. end;
  938. elseif Blockage.ClassName=="TrussPart"or Blockage.ClassName=="WedgePart"or Blockage.Name=="Handle"and Blockage.Parent:IsA("Hat")or Blockage.Name=="Handle"and Blockage.Parent:IsA("Tool")or MainTarget and Blockage:IsDescendantOf(MainTarget.Parent)or BlockageHumanoid~=nil then
  939. Jumpable=false;
  940. end;
  941. end;
  942. if StomedyScript and Stomedy and StomedyHumanoid and StomedyHumanoid.Health~=0 and not StomedyHumanoid.Sit and Jumpable then
  943. StomedyHumanoid.Jump=true;
  944. end;
  945. if StomedyScript and Stomedy and StomedyHead and StomedyHumanoidRootPart and StomedyHead:FindFirstChild("StomedyStep")and (StomedyHumanoidRootPart.Velocity-Vector3.new(0,StomedyHumanoidRootPart.Velocity.y,0)).magnitude>=5 and not WalkDebounce and StomedyHumanoid and StomedyHumanoid.Health~=0 then
  946. Spawn(function()
  947. WalkDebounce=true;
  948. local FiredRay=Ray.new(StomedyHumanoidRootPart.Position,Vector3.new(0,-4,0));
  949. local RayTarget,endPoint=Game:GetService("Workspace"):FindPartOnRay(FiredRay,Stomedy);
  950. if RayTarget then
  951. local StomedyHeadFootStepClone=StomedyHead:FindFirstChild("StomedyStep"):Clone();
  952. StomedyHeadFootStepClone.Parent=StomedyHead;
  953. StomedyHeadFootStepClone:Play();
  954. if StomedyScript and Stomedy and StomedyHumanoid and StomedyHumanoid.Health~=0 and StomedyHumanoid.WalkSpeed<17 then
  955. Wait(0.4);
  956. elseif StomedyScript and Stomedy and StomedyHumanoid and StomedyHumanoid.Health~=0 and StomedyHumanoid.WalkSpeed>17 then
  957. Wait(0.15);
  958. end
  959. end;
  960. WalkDebounce=false;
  961. end);
  962. end;
  963. local MainTarget=FindNearestBae();
  964. local FoundHumanoid;
  965. if MainTarget~=nil then
  966. for _,Child in pairs(MainTarget.Parent:GetChildren())do
  967. if Child~=nil and Child:IsA("Humanoid")and Child.Health~=0 then
  968. FoundHumanoid=Child;
  969. end;
  970. end;
  971. end;
  972. if StomedyScript and Stomedy and StomedyHumanoid and StomedyHumanoid.Health~=0 and MainTarget and MainTarget.Parent and FoundHumanoid~=nil and FoundHumanoid.Jump then
  973. StomedyHumanoid.Jump=true;
  974. end;
  975. if not AttackDebounce and StomedyScript~=nil and Stomedy~=nil and StomedyHumanoid~=nil and StomedyHumanoid.Health~=0 and StomedyHead~=nil and StomedyHead:FindFirstChild("StomedyHit")and MainTarget~=nil and FoundHumanoid~=nil and FoundHumanoid.Health~=0 and(MainTarget.Position-StomedyHumanoidRootPart.Position).magnitude<6 then
  976. local hit,pos=raycast(StomedyHumanoidRootPart.Position,(MainTarget.Position-StomedyHumanoidRootPart.Position).unit,500)
  977. if hit~=nil and hit:IsDescendantOf(MainTarget.Parent)then
  978. Spawn(function()
  979. AttackDebounce=true;
  980. local SwingAnimation=StomedyHumanoid:LoadAnimation(StomedyScript:FindFirstChild("Swing"));
  981. SwingAnimation:Play();
  982. SwingAnimation:AdjustSpeed(2+math.random()*0.6)
  983. local HitSoundClone=StomedyHead:FindFirstChild("StomedyHit"):Clone();
  984. HitSoundClone.Pitch=StomedyHead:FindFirstChild("StomedyHit").Pitch+math.random()*0.1;
  985. HitSoundClone.Parent=StomedyHead;
  986. HitSoundClone:Play();
  987. FoundHumanoid:TakeDamage(10);
  988. Wait(0.2+math.random()*0.2);
  989. AttackDebounce=false;
  990. end);
  991. end;
  992. end;
  993. if StomedyScript and Stomedy and StomedyHumanoid and StomedyHumanoid.Health~=0 and MainTarget and FoundHumanoid~=nil and FoundHumanoid.Health~=0 and(MainTarget.Position-StomedyHumanoidRootPart.Position).magnitude<150 then
  994. if StomedyScript and Stomedy and Stomedy:FindFirstChild("Cardboard")and not Stomedy:FindFirstChild("Cardboard").IsPlaying then
  995. Stomedy:FindFirstChild("Cardboard").Volume=1;
  996. Stomedy:FindFirstChild("Cardboard"):Play();
  997. end;
  998. elseif StomedyScript and Stomedy and StomedyHumanoid and StomedyHumanoid.Health~=0 and MainTarget and FoundHumanoid~=nil and FoundHumanoid.Health~=0 and(MainTarget.Position-StomedyHumanoidRootPart.Position).magnitude>150 then
  999. if StomedyScript and Stomedy and Stomedy:FindFirstChild("Cardboard")and Stomedy:FindFirstChild("Cardboard").IsPlaying then
  1000. if not MusicDebounce then
  1001. Spawn(function()
  1002. MusicDebounce=true;
  1003. repeat Wait(0);if StomedyScript and Stomedy and Stomedy:FindFirstChild("Cardboard")then Stomedy:FindFirstChild("Cardboard").Volume=Stomedy:FindFirstChild("Cardboard").Volume-0.01;else break;end;until Stomedy:FindFirstChild("Cardboard").Volume==0 or Stomedy:FindFirstChild("Cardboard").Volume<0;
  1004. if StomedyScript and Stomedy and Stomedy:FindFirstChild("Cardboard")then
  1005. Stomedy:FindFirstChild("Cardboard").Volume=0;
  1006. Stomedy:FindFirstChild("Cardboard"):Stop();
  1007. end;
  1008. MusicDebounce=false;
  1009. end);
  1010. end;
  1011. end;
  1012. end;
  1013. if not MainTarget and not MusicDebounce then
  1014. Spawn(function()
  1015. MusicDebounce=true;
  1016. repeat Wait(0);if StomedyScript and Stomedy and Stomedy:FindFirstChild("Cardboard")then Stomedy:FindFirstChild("Cardboard").Volume=Stomedy:FindFirstChild("Cardboard").Volume-0.01;else break;end;until Stomedy:FindFirstChild("Cardboard").Volume==0 or Stomedy:FindFirstChild("Cardboard").Volume<0;
  1017. if StomedyScript and Stomedy and Stomedy:FindFirstChild("Cardboard")then
  1018. Stomedy:FindFirstChild("Cardboard").Volume=0;
  1019. Stomedy:FindFirstChild("Cardboard"):Stop();
  1020. end;
  1021. MusicDebounce=false;
  1022. end);
  1023. end;
  1024. if MainTarget~=nil then
  1025. if StomedyScript and Stomedy and StomedyHumanoid and StomedyHumanoid.Health~=0 then
  1026. if MainTarget~=nil and FoundHumanoid~=nil and FoundHumanoid.Health~=0 and(MainTarget.Position-StomedyHumanoidRootPart.Position).magnitude>5 then
  1027. StomedyHumanoid.WalkSpeed=50;
  1028. elseif MainTarget~=nil and FoundHumanoid~=nil and FoundHumanoid.Health~=0 and(MainTarget.Position-StomedyHumanoidRootPart.Position).magnitude<5 then
  1029. StomedyHumanoid.WalkSpeed=10;
  1030. end;
  1031. end;
  1032. if StomedyScript~=nil and Stomedy~=nil and Stomedy:FindFirstChild("Torso")and Stomedy:FindFirstChild("Torso"):FindFirstChild("Neck")then
  1033. local NeckRotation=(Stomedy:FindFirstChild("Torso").Position.Y-MainTarget.Parent:FindFirstChild("Head").Position.Y)/10;
  1034. if NeckRotation>-1.5 and NeckRotation<1.5 then
  1035. if StomedyScript and Stomedy and Stomedy:FindFirstChild("Torso")and Stomedy:FindFirstChild("Torso"):FindFirstChild("Neck")then
  1036. Stomedy:FindFirstChild("Torso"):FindFirstChild("Neck").C0=OriginalC0*CFrame.fromEulerAnglesXYZ(NeckRotation,0,0);
  1037. end;
  1038. end;
  1039. if NeckRotation<-1.5 then
  1040. Stomedy:FindFirstChild("Torso"):FindFirstChild("Neck").C0=CFrame.new(0,1,0,-1,0,0,0,-0.993636549,0.112633869,0,0.112633869,0.993636549);
  1041. elseif NeckRotation>1.5 then
  1042. if StomedyScript and Stomedy and Stomedy:FindFirstChild("Torso")and Stomedy:FindFirstChild("Torso"):FindFirstChild("Neck")then
  1043. Stomedy:FindFirstChild("Torso"):FindFirstChild("Neck").C0=CFrame.new(0,1,0,-1,0,0,0,0.996671617,0.081521146,0,0.081521146,-0.996671617);
  1044. end;
  1045. end;
  1046. end;
  1047. else
  1048. if StomedyScript~=nil and Stomedy~=nil and Stomedy:FindFirstChild("Points")then
  1049. local PointsModel=Stomedy:FindFirstChild("Points");
  1050. if PointsModel~=nil and #PointsModel:GetChildren()~=0 then
  1051. PointsModel:ClearAllChildren();
  1052. end;
  1053. end;
  1054. if StomedyScript~=nil and Stomedy~=nil and Stomedy:FindFirstChild("Torso")and Stomedy:FindFirstChild("Torso"):FindFirstChild("Neck")then
  1055. Stomedy:FindFirstChild("Torso"):FindFirstChild("Neck").C0=CFrame.new(0,1,0,-1,0,0,0,0,1,0,1,-0);
  1056. end;
  1057. if StomedyScript and Stomedy and StomedyHumanoid then
  1058. StomedyHumanoid.WalkSpeed=12;
  1059. end;
  1060. local SwitchWander=math.random(1,2000);
  1061. if SwitchWander==1 and not DynamicWander then
  1062. DynamicWander=true;
  1063. elseif SwitchWander==1 and DynamicWander then
  1064. DynamicWander=false;
  1065. end;
  1066. local WalkChance=math.random(1,40);
  1067. if WalkChance==1 and StomedyScript and Stomedy and Stomedy:FindFirstChild("Torso")and Stomedy:FindFirstChild("Head")and StomedyHumanoid and StomedyHumanoid.Health>0.001 and not DynamicWander then
  1068. elseif StomedyScript and Stomedy and Stomedy:FindFirstChild("Torso")and Stomedy:FindFirstChild("Head")and StomedyHumanoid and StomedyHumanoid.Health>0.001 and DynamicWander then
  1069. local WanderAngle=(math.random()-0.5)*1;
  1070. local RotatingLookVector=CFrame.Angles(0,WanderAngle,0)*script.Parent.Torso.CFrame.lookVector;
  1071. StomedyHumanoid:MoveTo(Stomedy:FindFirstChild("Torso").Position+6*RotatingLookVector,Stomedy:FindFirstChild("Torso"));
  1072. end;
  1073. end;
  1074. if StomedyScript and Stomedy and StomedyHumanoid then
  1075. StomedyHumanoid.DisplayDistanceType="None";
  1076. StomedyHumanoid.HealthDisplayDistance=0;
  1077. StomedyHumanoid.NameDisplayDistance=0;
  1078. StomedyHumanoid.NameOcclusion="EnemyOcclusion";
  1079. StomedyHumanoid.AutoJumpEnabled=true;
  1080. StomedyHumanoid.AutoRotate=true;
  1081. StomedyHumanoid.MaxHealth=99999e99999;
  1082. StomedyHumanoid.Health=99999e99999;
  1083. StomedyHumanoid.JumpPower=100;
  1084. StomedyHumanoid.MaxSlopeAngle=89.9;
  1085. end;
  1086. if StomedyScript and Stomedy and StomedyHumanoid and not StomedyHumanoid.AutoJumpEnabled then
  1087. StomedyHumanoid.AutoJumpEnabled=true;
  1088. end;
  1089. if StomedyScript and Stomedy and StomedyHumanoid and not StomedyHumanoid.AutoRotate then
  1090. StomedyHumanoid.AutoRotate=true;
  1091. end;
  1092. if StomedyScript and Stomedy and StomedyHumanoid and StomedyHumanoid.PlatformStand then
  1093. StomedyHumanoid.PlatformStand=false;
  1094. end;
  1095. if StomedyScript and Stomedy and StomedyHumanoid and StomedyHumanoid.Sit then
  1096. StomedyHumanoid.Sit=false;
  1097. end;
  1098. end;
  1099. --[[ By: Brutez. ]]--
  1100. end))
  1101. Animation46.Name = "Swing"
  1102. Animation46.Parent = Script45
  1103. Animation46.AnimationId = "rbxassetid://191123156"
  1104. CharacterMesh47.Name = "Roblox 3.0 Right Leg"
  1105. CharacterMesh47.Parent = Model0
  1106. CharacterMesh47.MeshId = 81487710
  1107. CharacterMesh47.BodyPart = Enum.BodyPart.RightLeg
  1108. CharacterMesh48.Name = "Roblox 3.0 torso"
  1109. CharacterMesh48.Parent = Model0
  1110. CharacterMesh48.MeshId = 82907945
  1111. CharacterMesh48.BodyPart = Enum.BodyPart.Torso
  1112. CharacterMesh49.Name = "Roblox 3.0 Left Arm"
  1113. CharacterMesh49.Parent = Model0
  1114. CharacterMesh49.MeshId = 82907977
  1115. CharacterMesh49.BodyPart = Enum.BodyPart.LeftArm
  1116. CharacterMesh50.Name = "Roblox 3.0 Left Leg"
  1117. CharacterMesh50.Parent = Model0
  1118. CharacterMesh50.MeshId = 81487640
  1119. CharacterMesh50.BodyPart = Enum.BodyPart.LeftLeg
  1120. CharacterMesh51.Name = "Roblox 3.0 Right Arm"
  1121. CharacterMesh51.Parent = Model0
  1122. CharacterMesh51.MeshId = 82908019
  1123. CharacterMesh51.BodyPart = Enum.BodyPart.RightArm
  1124. Shirt52.Name = "Shirt"
  1125. Shirt52.Parent = Model0
  1126. Shirt52.ShirtTemplate = "http://www.roblox.com/asset/?id=359526867"
  1127. Pants53.Name = "Pants"
  1128. Pants53.Parent = Model0
  1129. Pants53.PantsTemplate = "http://www.roblox.com/asset/?id=242081979"
  1130. Hat54.Name = "RoboKnitHat"
  1131. Hat54.Parent = Model0
  1132. Hat54.AttachmentPos = Vector3.new(0, 0.200000003, 0)
  1133. Part55.Name = "Handle"
  1134. Part55.Parent = Hat54
  1135. Part55.Rotation = Vector3.new(0, -57.8199997, 0)
  1136. Part55.Velocity = Vector3.new(1.40129846e-45, 0, 1.40129846e-45)
  1137. Part55.CanCollide = false
  1138. Part55.Locked = true
  1139. Part55.FormFactor = Enum.FormFactor.Custom
  1140. Part55.Size = Vector3.new(1.84000015, 1.79000008, 2.03999972)
  1141. Part55.CFrame = CFrame.new(20.9954529, 4.80000925, 7.42480421, 0.53263253, 0, -0.846346557, 0, 1, 0, 0.846346557, 0, 0.53263253)
  1142. Part55.BottomSurface = Enum.SurfaceType.Smooth
  1143. Part55.TopSurface = Enum.SurfaceType.Smooth
  1144. Part55.Position = Vector3.new(20.9954529, 4.80000925, 7.42480421)
  1145. Part55.Orientation = Vector3.new(0, -57.8199997, 0)
  1146. SpecialMesh56.Parent = Part55
  1147. SpecialMesh56.MeshId = "http://www.roblox.com/asset/?id=215693829 "
  1148. SpecialMesh56.TextureId = "http://www.roblox.com/asset/?id=215694384 "
  1149. SpecialMesh56.MeshType = Enum.MeshType.FileMesh
  1150. Script57.Name = "MonsterScript"
  1151. Script57.Parent = Model0
  1152. table.insert(cors,sandbox(Script57,function()
  1153. --[[
  1154. Basic Monster by ArceusInator
  1155.  
  1156. Information:
  1157. Configurations.MaximumDetectionDistance (default 200)
  1158. The monster will not detect players past this point. If you set it to a negative number then the monster will be able to chase from any distance.
  1159.  
  1160. Configurations.CanGiveUp (default true)
  1161. If true, the monster will give up if its target goes past the MaximumDetectionDistance. This is a pretty good idea if you have people teleporting around.
  1162.  
  1163. Configurations.CanRespawn (default true)
  1164. If true, the monster will respawn after it dies
  1165.  
  1166. Configurations.AutoDetectSpawnPoint (default true)
  1167. If true, the spawn point will be auto detected based on where the monster is when it starts
  1168.  
  1169. Configurations.SpawnPoint (default 0,0,0)
  1170. If Settings.AutoDetectSpawnPoint is disabled, this will be set to the monster's initial position. This value will be used when the monster auto respawns to tell it where to spawn next.
  1171.  
  1172. Configurations.FriendlyTeam (default Really black)
  1173. The monster will not attack players on this team
  1174.  
  1175.  
  1176.  
  1177. Mind.CurrentTargetHumanoid (Humanoid objects only)
  1178. You can force the monster to follow a certain humanoid by setting this to that humanoid
  1179.  
  1180.  
  1181.  
  1182. Monster.Respawn (Function)
  1183. Arguments are: Vector3 point
  1184. Info: Respawns the monster at the given point, or at the SpawnPoint setting if none if provided
  1185.  
  1186. Monster.Died (Event)
  1187. Info: Fired when the monster dies
  1188.  
  1189. Monster.Respawned (Event)
  1190. Info: Fired when the monster respawns
  1191. --]]
  1192.  
  1193. local Self = script.Parent
  1194. local Settings = Self:FindFirstChild'Configurations' -- Points to the settings.
  1195. local Mind = Self:FindFirstChild'Mind' -- Points to the monster's mind. You can edit parts of this from other scripts in-game to change the monster's behavior. Advanced users only.
  1196.  
  1197. --
  1198. -- Verify that everything is where it should be
  1199. assert(Self:FindFirstChild'Humanoid' ~= nil, 'Monster does not have a humanoid')
  1200. assert(Settings ~= nil, 'Monster does not have a Configurations object')
  1201. assert(Settings:FindFirstChild'MaximumDetectionDistance' ~= nil and Settings.MaximumDetectionDistance:IsA'NumberValue', 'Monster does not have a MaximumDetectionDistance (NumberValue) setting')
  1202. assert(Settings:FindFirstChild'CanGiveUp' ~= nil and Settings.CanGiveUp:IsA'BoolValue', 'Monster does not have a CanGiveUp (BoolValue) setting')
  1203. assert(Settings:FindFirstChild'CanRespawn' ~= nil and Settings.CanRespawn:IsA'BoolValue', 'Monster does not have a CanRespawn (BoolValue) setting')
  1204. assert(Settings:FindFirstChild'SpawnPoint' ~= nil and Settings.SpawnPoint:IsA'Vector3Value', 'Monster does not have a SpawnPoint (Vector3Value) setting')
  1205. assert(Settings:FindFirstChild'AutoDetectSpawnPoint' ~= nil and Settings.AutoDetectSpawnPoint:IsA'BoolValue', 'Monster does not have a AutoDetectSpawnPoint (BoolValue) setting')
  1206. assert(Settings:FindFirstChild'FriendlyTeam' ~= nil and Settings.FriendlyTeam:IsA'BrickColorValue', 'Monster does not have a FriendlyTeam (BrickColorValue) setting')
  1207. assert(Settings:FindFirstChild'AttackDamage' ~= nil and Settings.AttackDamage:IsA'NumberValue', 'Monster does not have a AttackDamage (NumberValue) setting')
  1208. assert(Settings:FindFirstChild'AttackFrequency' ~= nil and Settings.AttackFrequency:IsA'NumberValue', 'Monster does not have a AttackFrequency (NumberValue) setting')
  1209. assert(Settings:FindFirstChild'AttackRange' ~= nil and Settings.AttackRange:IsA'NumberValue', 'Monster does not have a AttackRange (NumberValue) setting')
  1210. assert(Mind ~= nil, 'Monster does not have a Mind object')
  1211. assert(Mind:FindFirstChild'CurrentTargetHumanoid' ~= nil and Mind.CurrentTargetHumanoid:IsA'ObjectValue', 'Monster does not have a CurrentTargetHumanoid (ObjectValue) mind setting')
  1212. assert(Self:FindFirstChild'Respawn' and Self.Respawn:IsA'BindableFunction', 'Monster does not have a Respawn BindableFunction')
  1213. assert(Self:FindFirstChild'Died' and Self.Died:IsA'BindableEvent', 'Monster does not have a Died BindableEvent')
  1214. assert(Self:FindFirstChild'Respawned' and Self.Died:IsA'BindableEvent', 'Monster does not have a Respawned BindableEvent')
  1215. assert(Self:FindFirstChild'Attacked' and Self.Died:IsA'BindableEvent', 'Monster does not have a Attacked BindableEvent')
  1216. assert(script:FindFirstChild'Attack' and script.Attack:IsA'Animation', 'Monster does not have a MonsterScript.Attack Animation')
  1217.  
  1218.  
  1219. --
  1220. --
  1221. local Info = {
  1222. -- These are constant values. Don't change them unless you know what you're doing.
  1223.  
  1224. -- Services
  1225. Players = Game:GetService 'Players',
  1226. PathfindingService = Game:GetService 'PathfindingService',
  1227.  
  1228. -- Advanced settings
  1229. RecomputePathFrequency = 1, -- The monster will recompute its path this many times per second
  1230. RespawnWaitTime = 5, -- How long to wait before the monster respawns
  1231. JumpCheckFrequency = 1, -- How many times per second it will do a jump check
  1232. }
  1233. local Data = {
  1234. -- These are variable values used internally by the script. Advanced users only.
  1235.  
  1236. LastRecomputePath = 0,
  1237. Recomputing = false, -- Reocmputing occurs async, meaning this script will still run while it's happening. This variable will prevent the script from running two recomputes at once.
  1238. PathCoords = {},
  1239. IsDead = false,
  1240. TimeOfDeath = 0,
  1241. CurrentNode = nil,
  1242. CurrentNodeIndex = 1,
  1243. AutoRecompute = true,
  1244. LastJumpCheck = 0,
  1245. LastAttack = 0,
  1246.  
  1247. BaseMonster = Self:Clone(),
  1248. AttackTrack = nil,
  1249. }
  1250.  
  1251. --
  1252. --
  1253. local Monster = {} -- Create the monster class
  1254.  
  1255.  
  1256. function Monster:GetCFrame()
  1257. -- Returns the CFrame of the monster's humanoidrootpart
  1258.  
  1259. local humanoidRootPart = Self:FindFirstChild('HumanoidRootPart')
  1260.  
  1261. if humanoidRootPart ~= nil and humanoidRootPart:IsA('BasePart') then
  1262. return humanoidRootPart.CFrame
  1263. else
  1264. return CFrame.new()
  1265. end
  1266. end
  1267.  
  1268. function Monster:GetMaximumDetectionDistance()
  1269. -- Returns the maximum detection distance
  1270.  
  1271. local setting = Settings.MaximumDetectionDistance.Value
  1272.  
  1273. if setting < 0 then
  1274. return math.huge
  1275. else
  1276. return setting
  1277. end
  1278. end
  1279.  
  1280. function Monster:SearchForTarget()
  1281. -- Finds the closest player and sets the target
  1282.  
  1283. local players = Info.Players:GetPlayers()
  1284. local closestCharacter, closestCharacterDistance
  1285.  
  1286. for i=1, #players do
  1287. local player = players[i]
  1288.  
  1289. if player.Neutral or player.TeamColor ~= Settings.FriendlyTeam.Value then
  1290. local character = player.Character
  1291.  
  1292. if character ~= nil and character:FindFirstChild('Humanoid') ~= nil and character.Humanoid:IsA('Humanoid') then
  1293. local distance = player:DistanceFromCharacter(Monster:GetCFrame().p)
  1294.  
  1295. if distance < Monster:GetMaximumDetectionDistance() then
  1296. if closestCharacter == nil then
  1297. closestCharacter, closestCharacterDistance = character, distance
  1298. else
  1299. if closestCharacterDistance > distance then
  1300. closestCharacter, closestCharacterDistance = character, distance
  1301. end
  1302. end
  1303. end
  1304. end
  1305. end
  1306. end
  1307.  
  1308.  
  1309. if closestCharacter ~= nil then
  1310. Mind.CurrentTargetHumanoid.Value = closestCharacter.Humanoid
  1311. end
  1312. end
  1313.  
  1314. function Monster:TryRecomputePath()
  1315. if Data.AutoRecompute or tick() - Data.LastRecomputePath > 1/Info.RecomputePathFrequency then
  1316. Monster:RecomputePath()
  1317. end
  1318. end
  1319.  
  1320. function Monster:GetTargetCFrame()
  1321. local targetHumanoid = Mind.CurrentTargetHumanoid.Value
  1322.  
  1323. if Monster:TargetIsValid() then
  1324. return targetHumanoid.Torso.CFrame
  1325. else
  1326. return CFrame.new()
  1327. end
  1328. end
  1329.  
  1330. function Monster:IsAlive()
  1331. return Self.Humanoid.Health > 0 and Self.Humanoid.Torso ~= nil
  1332. end
  1333.  
  1334. function Monster:TargetIsValid()
  1335. local targetHumanoid = Mind.CurrentTargetHumanoid.Value
  1336.  
  1337. if targetHumanoid ~= nil and targetHumanoid:IsA 'Humanoid' and targetHumanoid.Torso ~= nil and targetHumanoid.Torso:IsA 'BasePart' then
  1338. return true
  1339. else
  1340. return false
  1341. end
  1342. end
  1343.  
  1344. function Monster:HasClearLineOfSight()
  1345. -- Going to cast a ray to see if I can just see my target
  1346. local myPos, targetPos = Monster:GetCFrame().p, Monster:GetTargetCFrame().p
  1347.  
  1348. local hit, pos = Workspace:FindPartOnRayWithIgnoreList(
  1349. Ray.new(
  1350. myPos,
  1351. targetPos - myPos
  1352. ),
  1353. {
  1354. Self,
  1355. Mind.CurrentTargetHumanoid.Value.Parent
  1356. }
  1357. )
  1358.  
  1359.  
  1360. if hit == nil then
  1361. return true
  1362. else
  1363. return false
  1364. end
  1365. end
  1366.  
  1367. function Monster:RecomputePath()
  1368. if not Data.Recomputing then
  1369. if Monster:IsAlive() and Monster:TargetIsValid() then
  1370. if Monster:HasClearLineOfSight() then
  1371. Data.AutoRecompute = true
  1372. Data.PathCoords = {
  1373. Monster:GetCFrame().p,
  1374. Monster:GetTargetCFrame().p
  1375. }
  1376.  
  1377. Data.LastRecomputePath = tick()
  1378. Data.CurrentNode = nil
  1379. Data.CurrentNodeIndex = 2 -- Starts chasing the target without evaluating its current position
  1380. else
  1381. -- Do pathfinding since you can't walk straight
  1382. Data.Recomputing = true -- Basically a debounce.
  1383. Data.AutoRecompute = false
  1384.  
  1385.  
  1386. local path = Info.PathfindingService:ComputeSmoothPathAsync(
  1387. Monster:GetCFrame().p,
  1388. Monster:GetTargetCFrame().p,
  1389. 500
  1390. )
  1391. Data.PathCoords = path:GetPointCoordinates()
  1392.  
  1393.  
  1394. Data.Recomputing = false
  1395. Data.LastRecomputePath = tick()
  1396. Data.CurrentNode = nil
  1397. Data.CurrentNodeIndex = 1
  1398. end
  1399. end
  1400. end
  1401. end
  1402.  
  1403. function Monster:Update()
  1404. Monster:ReevaluateTarget()
  1405. Monster:SearchForTarget()
  1406. Monster:TryRecomputePath()
  1407. Monster:TravelPath()
  1408. end
  1409.  
  1410. function Monster:TravelPath()
  1411. local closest, closestDistance, closestIndex
  1412. local myPosition = Monster:GetCFrame().p
  1413. local skipCurrentNode = Data.CurrentNode ~= nil and (Data.CurrentNode - myPosition).magnitude < 3
  1414.  
  1415. for i=Data.CurrentNodeIndex, #Data.PathCoords do
  1416. local coord = Data.PathCoords[i]
  1417. if not (skipCurrentNode and coord == Data.CurrentNode) then
  1418. local distance = (coord - myPosition).magnitude
  1419.  
  1420. if closest == nil then
  1421. closest, closestDistance, closestIndex = coord, distance, i
  1422. else
  1423. if distance < closestDistance then
  1424. closest, closestDistance, closestIndex = coord, distance, i
  1425. else
  1426. break
  1427. end
  1428. end
  1429. end
  1430. end
  1431.  
  1432.  
  1433. --
  1434. if closest ~= nil then
  1435. Data.CurrentNode = closest
  1436. Data.CurrentNodeIndex = closestIndex
  1437.  
  1438. local humanoid = Self:FindFirstChild 'Humanoid'
  1439.  
  1440. if humanoid ~= nil and humanoid:IsA'Humanoid' then
  1441. humanoid:MoveTo(closest)
  1442. end
  1443.  
  1444. if Monster:IsAlive() and Monster:TargetIsValid() then
  1445. Monster:TryJumpCheck()
  1446. Monster:TryAttack()
  1447. end
  1448.  
  1449. if closestIndex == #Data.PathCoords then
  1450. -- Reached the end of the path, force a new check
  1451. Data.AutoRecompute = true
  1452. end
  1453. end
  1454. end
  1455.  
  1456. function Monster:TryJumpCheck()
  1457. if tick() - Data.LastJumpCheck > 1/Info.JumpCheckFrequency then
  1458. Monster:JumpCheck()
  1459. end
  1460. end
  1461.  
  1462. function Monster:TryAttack()
  1463. if tick() - Data.LastAttack > 1/Settings.AttackFrequency.Value then
  1464. Monster:Attack()
  1465. end
  1466. end
  1467.  
  1468. function Monster:Attack()
  1469. local myPos, targetPos = Monster:GetCFrame().p, Monster:GetTargetCFrame().p
  1470.  
  1471. if (myPos - targetPos).magnitude <= Settings.AttackRange.Value then
  1472. Mind.CurrentTargetHumanoid.Value:TakeDamage(Settings.AttackDamage.Value)
  1473. Data.LastAttack = tick()
  1474. Data.AttackTrack:Play()
  1475. end
  1476. end
  1477.  
  1478. function Monster:JumpCheck()
  1479. -- Do a raycast to check if we need to jump
  1480. local myCFrame = Monster:GetCFrame()
  1481. local checkVector = (Monster:GetTargetCFrame().p - myCFrame.p).unit*2
  1482.  
  1483. local hit, pos = Workspace:FindPartOnRay(
  1484. Ray.new(
  1485. myCFrame.p + Vector3.new(0, -2.4, 0),
  1486. checkVector
  1487. ),
  1488. Self
  1489. )
  1490.  
  1491. if hit ~= nil and not hit:IsDescendantOf(Mind.CurrentTargetHumanoid.Value.Parent) then
  1492. -- Do a slope check to make sure we're not walking up a ramp
  1493.  
  1494. local hit2, pos2 = Workspace:FindPartOnRay(
  1495. Ray.new(
  1496. myCFrame.p + Vector3.new(0, -2.3, 0),
  1497. checkVector
  1498. ),
  1499. Self
  1500. )
  1501.  
  1502. if hit2 == hit then
  1503. if ((pos2 - pos)*Vector3.new(1,0,1)).magnitude < 0.05 then -- Will pass for any ramp with <2 slope
  1504. Self.Humanoid.Jump = true
  1505. end
  1506. end
  1507. end
  1508.  
  1509. Data.LastJumpCheck = tick()
  1510. end
  1511.  
  1512. function Monster:Connect()
  1513. Mind.CurrentTargetHumanoid.Changed:connect(function(humanoid)
  1514. if humanoid ~= nil then
  1515. assert(humanoid:IsA'Humanoid', 'Monster target must be a humanoid')
  1516.  
  1517. Monster:RecomputePath()
  1518. end
  1519. end)
  1520.  
  1521. Self.Respawn.OnInvoke = function(point)
  1522. Monster:Respawn(point)
  1523. end
  1524. end
  1525.  
  1526. function Monster:Initialize()
  1527. Monster:Connect()
  1528.  
  1529. if Settings.AutoDetectSpawnPoint.Value then
  1530. Settings.SpawnPoint.Value = Monster:GetCFrame().p
  1531. end
  1532. end
  1533.  
  1534. function Monster:Respawn(point)
  1535. local point = point or Settings.SpawnPoint.Value
  1536.  
  1537. for index, obj in next, Data.BaseMonster:Clone():GetChildren() do
  1538. if obj.Name == 'Configurations' or obj.Name == 'Mind' or obj.Name == 'Respawned' or obj.Name == 'Died' or obj.Name == 'MonsterScript' or obj.Name == 'Respawn' then
  1539. obj:Destroy()
  1540. else
  1541. Self[obj.Name]:Destroy()
  1542. obj.Parent = Self
  1543. end
  1544. end
  1545.  
  1546. Monster:InitializeUnique()
  1547.  
  1548. Self.Parent = Workspace
  1549.  
  1550. Self.HumanoidRootPart.CFrame = CFrame.new(point)
  1551. Settings.SpawnPoint.Value = point
  1552. Self.Respawned:Fire()
  1553. end
  1554.  
  1555. function Monster:InitializeUnique()
  1556. Data.AttackTrack = Self.Humanoid:LoadAnimation(script.Attack)
  1557. end
  1558.  
  1559. function Monster:ReevaluateTarget()
  1560. local currentTarget = Mind.CurrentTargetHumanoid.Value
  1561.  
  1562. if currentTarget ~= nil and currentTarget:IsA'Humanoid' then
  1563. local character = currentTarget.Parent
  1564.  
  1565. if character ~= nil then
  1566. local player = Info.Players:GetPlayerFromCharacter(character)
  1567.  
  1568. if player ~= nil then
  1569. if not player.Neutral and player.TeamColor == Settings.FriendlyTeam.Value then
  1570. Mind.CurrentTargetHumanoid.Value = nil
  1571. end
  1572. end
  1573. end
  1574.  
  1575.  
  1576. if currentTarget == Mind.CurrentTargetHumanoid.Value then
  1577. local torso = currentTarget.Torso
  1578.  
  1579. if torso ~= nil and torso:IsA 'BasePart' then
  1580. if Settings.CanGiveUp.Value and (torso.Position - Monster:GetCFrame().p).magnitude > Monster:GetMaximumDetectionDistance() then
  1581. Mind.CurrentTargetHumanoid.Value = nil
  1582. end
  1583. end
  1584. end
  1585. end
  1586. end
  1587.  
  1588. --
  1589. --
  1590. Monster:Initialize()
  1591. Monster:InitializeUnique()
  1592.  
  1593. while true do
  1594. if not Monster:IsAlive() then
  1595. if Data.IsDead == false then
  1596. Data.IsDead = true
  1597. Data.TimeOfDeath = tick()
  1598. Self.Died:Fire()
  1599. end
  1600. if Data.IsDead == true then
  1601. if tick()-Data.TimeOfDeath > Info.RespawnWaitTime then
  1602. Monster:Respawn()
  1603. end
  1604. end
  1605. end
  1606.  
  1607. if Monster:IsAlive() then
  1608. Monster:Update()
  1609. end
  1610.  
  1611. wait()
  1612. end
  1613. end))
  1614. Animation58.Name = "Attack"
  1615. Animation58.Parent = Script57
  1616. Animation58.AnimationId = "rbxassetid://0"
  1617. BindableFunction59.Name = "Respawn"
  1618. BindableFunction59.Parent = Model0
  1619. BindableEvent60.Name = "Attacked"
  1620. BindableEvent60.Parent = Model0
  1621. BindableEvent61.Name = "Died"
  1622. BindableEvent61.Parent = Model0
  1623. BindableEvent62.Name = "Respawned"
  1624. BindableEvent62.Parent = Model0
  1625. Configuration63.Name = "Mind"
  1626. Configuration63.Parent = Model0
  1627. ObjectValue64.Name = "CurrentTargetHumanoid"
  1628. ObjectValue64.Parent = Configuration63
  1629. Configuration65.Name = "Configurations"
  1630. Configuration65.Parent = Model0
  1631. NumberValue66.Name = "MaximumDetectionDistance"
  1632. NumberValue66.Parent = Configuration65
  1633. NumberValue66.Value = 200
  1634. BoolValue67.Name = "CanGiveUp"
  1635. BoolValue67.Parent = Configuration65
  1636. BoolValue67.Value = true
  1637. BoolValue68.Name = "CanRespawn"
  1638. BoolValue68.Parent = Configuration65
  1639. BoolValue68.Value = true
  1640. Vector3Value69.Name = "SpawnPoint"
  1641. Vector3Value69.Parent = Configuration65
  1642. Vector3Value69.Value = Vector3.new(24.2997856, 5.00000095, -33.0201225)
  1643. BoolValue70.Name = "AutoDetectSpawnPoint"
  1644. BoolValue70.Parent = Configuration65
  1645. BoolValue70.Value = true
  1646. BrickColorValue71.Name = "FriendlyTeam"
  1647. BrickColorValue71.Parent = Configuration65
  1648. BrickColorValue71.Value = BrickColor.new("Really black")
  1649. NumberValue72.Name = "AttackDamage"
  1650. NumberValue72.Parent = Configuration65
  1651. NumberValue73.Name = "AttackFrequency"
  1652. NumberValue73.Parent = Configuration65
  1653. NumberValue73.Value = 2
  1654. NumberValue74.Name = "AttackRange"
  1655. NumberValue74.Parent = Configuration65
  1656. NumberValue74.Value = 3
  1657. for i,v in pairs(mas:GetChildren()) do
  1658. v.Parent = workspace
  1659. pcall(function() v:MakeJoints() end)
  1660. end
  1661. mas:Destroy()
  1662. for i,v in pairs(cors) do
  1663. spawn(function()
  1664. pcall(v)
  1665. end)
  1666. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement