Advertisement
HenloMyDude

cloner thing

Aug 20th, 2019
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.84 KB | None | 0 0
  1. --Converted with ttyyuu12345's model to script plugin v4
  2. function sandbox(var,func)
  3. local env = getfenv(func)
  4. local newenv = setmetatable({},{
  5. __index = function(self,k)
  6. if k=="script" then
  7. return var
  8. else
  9. return env[k]
  10. end
  11. end,
  12. })
  13. setfenv(func,newenv)
  14. return func
  15. end
  16. cors = {}
  17. mas = Instance.new("Model",game:GetService("Lighting"))
  18. Model0 = Instance.new("Model")
  19. Part1 = Instance.new("Part")
  20. Motor6D2 = Instance.new("Motor6D")
  21. Part3 = Instance.new("Part")
  22. BodyForce4 = Instance.new("BodyForce")
  23. Motor6D5 = Instance.new("Motor6D")
  24. Motor6D6 = Instance.new("Motor6D")
  25. Motor6D7 = Instance.new("Motor6D")
  26. Motor6D8 = Instance.new("Motor6D")
  27. Motor6D9 = Instance.new("Motor6D")
  28. Part10 = Instance.new("Part")
  29. Part11 = Instance.new("Part")
  30. Part12 = Instance.new("Part")
  31. Part13 = Instance.new("Part")
  32. Part14 = Instance.new("Part")
  33. SpecialMesh15 = Instance.new("SpecialMesh")
  34. Humanoid16 = Instance.new("Humanoid")
  35. Script17 = Instance.new("Script")
  36. StringValue18 = Instance.new("StringValue")
  37. Animation19 = Instance.new("Animation")
  38. StringValue20 = Instance.new("StringValue")
  39. Animation21 = Instance.new("Animation")
  40. StringValue22 = Instance.new("StringValue")
  41. Animation23 = Instance.new("Animation")
  42. NumberValue24 = Instance.new("NumberValue")
  43. Animation25 = Instance.new("Animation")
  44. NumberValue26 = Instance.new("NumberValue")
  45. StringValue27 = Instance.new("StringValue")
  46. Animation28 = Instance.new("Animation")
  47. StringValue29 = Instance.new("StringValue")
  48. Animation30 = Instance.new("Animation")
  49. StringValue31 = Instance.new("StringValue")
  50. Animation32 = Instance.new("Animation")
  51. StringValue33 = Instance.new("StringValue")
  52. Animation34 = Instance.new("Animation")
  53. BodyColors35 = Instance.new("BodyColors")
  54. Script36 = Instance.new("Script")
  55. Shirt37 = Instance.new("Shirt")
  56. Pants38 = Instance.new("Pants")
  57. Model0.Name = "Clone"
  58. Model0.Parent = mas
  59. Part1.Name = "HumanoidRootPart"
  60. Part1.Parent = Model0
  61. Part1.CFrame = CFrame.new(-29.7313805, 2.99998093, -59.1259232, 4.49369422e-21, 7.01608598e-23, -1, -8.6405519e-23, 0.999991894, 7.01614782e-23, 1, 8.64048753e-23, 4.49369422e-21)
  62. Part1.Orientation = Vector3.new(0, -90, 0)
  63. Part1.Position = Vector3.new(-29.7313805, 2.99998093, -59.1259232)
  64. Part1.Rotation = Vector3.new(0, -90, 0)
  65. Part1.Color = Color3.new(0.152941, 0.27451, 0.176471)
  66. Part1.Transparency = 1
  67. Part1.Size = Vector3.new(2, 2, 1)
  68. Part1.BottomSurface = Enum.SurfaceType.Smooth
  69. Part1.BrickColor = BrickColor.new("Earth green")
  70. Part1.Material = Enum.Material.SmoothPlastic
  71. Part1.TopSurface = Enum.SurfaceType.Smooth
  72. Part1.brickColor = BrickColor.new("Earth green")
  73. Part1.FormFactor = Enum.FormFactor.Symmetric
  74. Part1.formFactor = Enum.FormFactor.Symmetric
  75. Motor6D2.Name = "Root Hip"
  76. Motor6D2.Parent = Part1
  77. Motor6D2.MaxVelocity = 0.10000000149012
  78. Motor6D2.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  79. Motor6D2.C1 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  80. Motor6D2.Part0 = Part1
  81. Motor6D2.Part1 = Part3
  82. Motor6D2.part1 = Part3
  83. Part3.Name = "Torso"
  84. Part3.Parent = Model0
  85. Part3.CFrame = CFrame.new(-29.7313805, 2.99998093, -59.1259232, 4.49369422e-21, 7.01608598e-23, -1, -8.6405519e-23, 0.999991894, 7.01614782e-23, 1, 8.64048753e-23, 4.49369422e-21)
  86. Part3.Orientation = Vector3.new(0, -90, 0)
  87. Part3.Position = Vector3.new(-29.7313805, 2.99998093, -59.1259232)
  88. Part3.Rotation = Vector3.new(0, -90, 0)
  89. Part3.Color = Color3.new(0.105882, 0.164706, 0.207843)
  90. Part3.Size = Vector3.new(2, 2, 1)
  91. Part3.BottomSurface = Enum.SurfaceType.Smooth
  92. Part3.BrickColor = BrickColor.new("Black")
  93. Part3.Material = Enum.Material.SmoothPlastic
  94. Part3.TopSurface = Enum.SurfaceType.Smooth
  95. Part3.brickColor = BrickColor.new("Black")
  96. Part3.FormFactor = Enum.FormFactor.Symmetric
  97. Part3.formFactor = Enum.FormFactor.Symmetric
  98. BodyForce4.Name = "RepulsionForce"
  99. BodyForce4.Parent = Part3
  100. BodyForce4.Force = Vector3.new(0, 0, 0)
  101. BodyForce4.force = Vector3.new(0, 0, 0)
  102. Motor6D5.Name = "Right Shoulder"
  103. Motor6D5.Parent = Part3
  104. Motor6D5.MaxVelocity = 0.10000000149012
  105. Motor6D5.C0 = CFrame.new(1, 0.5, 0, -4.37113883e-08, 0, 1, -0, 0.99999994, 0, -1, 0, -4.37113883e-08)
  106. Motor6D5.C1 = CFrame.new(-0.5, 0.5, 0, -4.37113883e-08, 0, 1, 0, 0.99999994, 0, -1, 0, -4.37113883e-08)
  107. Motor6D5.Part0 = Part3
  108. Motor6D5.Part1 = Part13
  109. Motor6D5.part1 = Part13
  110. Motor6D6.Name = "Left Shoulder"
  111. Motor6D6.Parent = Part3
  112. Motor6D6.MaxVelocity = 0.10000000149012
  113. Motor6D6.C0 = CFrame.new(-1, 0.5, 0, -4.37113883e-08, 0, -1, 0, 0.99999994, 0, 1, 0, -4.37113883e-08)
  114. Motor6D6.C1 = CFrame.new(0.5, 0.5, 0, -4.37113883e-08, 0, -1, 0, 0.99999994, 0, 1, 0, -4.37113883e-08)
  115. Motor6D6.Part0 = Part3
  116. Motor6D6.Part1 = Part12
  117. Motor6D6.part1 = Part12
  118. Motor6D7.Name = "Right Hip"
  119. Motor6D7.Parent = Part3
  120. Motor6D7.MaxVelocity = 0.10000000149012
  121. Motor6D7.C0 = CFrame.new(1, -1, 0, -4.37113883e-08, 0, 1, -0, 0.99999994, 0, -1, 0, -4.37113883e-08)
  122. Motor6D7.C1 = CFrame.new(0.5, 1, 0, -4.37113883e-08, 0, 1, 0, 0.99999994, 0, -1, 0, -4.37113883e-08)
  123. Motor6D7.Part0 = Part3
  124. Motor6D7.Part1 = Part11
  125. Motor6D7.part1 = Part11
  126. Motor6D8.Name = "Left Hip"
  127. Motor6D8.Parent = Part3
  128. Motor6D8.MaxVelocity = 0.10000000149012
  129. Motor6D8.C0 = CFrame.new(-1, -1, 0, -4.37113883e-08, 0, -1, 0, 0.99999994, 0, 1, 0, -4.37113883e-08)
  130. Motor6D8.C1 = CFrame.new(-0.5, 1, 0, -4.37113883e-08, 0, -1, 0, 0.99999994, 0, 1, 0, -4.37113883e-08)
  131. Motor6D8.Part0 = Part3
  132. Motor6D8.Part1 = Part10
  133. Motor6D8.part1 = Part10
  134. Motor6D9.Name = "Neck"
  135. Motor6D9.Parent = Part3
  136. Motor6D9.MaxVelocity = 0.10000000149012
  137. Motor6D9.C0 = CFrame.new(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  138. Motor6D9.C1 = CFrame.new(0, -0.5, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  139. Motor6D9.Part0 = Part3
  140. Motor6D9.Part1 = Part14
  141. Motor6D9.part1 = Part14
  142. Part10.Name = "Left Leg"
  143. Part10.Parent = Model0
  144. Part10.CFrame = CFrame.new(-29.7313805, 0.999997258, -59.6259232, 4.49369422e-21, 7.01608535e-23, -1, -8.6405519e-23, 0.999991775, 7.01614782e-23, 1, 8.64048626e-23, 4.49369422e-21)
  145. Part10.Orientation = Vector3.new(0, -90, 0)
  146. Part10.Position = Vector3.new(-29.7313805, 0.999997258, -59.6259232)
  147. Part10.Rotation = Vector3.new(0, -90, 0)
  148. Part10.Color = Color3.new(0.498039, 0.556863, 0.392157)
  149. Part10.Size = Vector3.new(1, 2, 1)
  150. Part10.BottomSurface = Enum.SurfaceType.Smooth
  151. Part10.BrickColor = BrickColor.new("Grime")
  152. Part10.CanCollide = false
  153. Part10.Material = Enum.Material.SmoothPlastic
  154. Part10.TopSurface = Enum.SurfaceType.Smooth
  155. Part10.brickColor = BrickColor.new("Grime")
  156. Part10.FormFactor = Enum.FormFactor.Symmetric
  157. Part10.formFactor = Enum.FormFactor.Symmetric
  158. Part11.Name = "Right Leg"
  159. Part11.Parent = Model0
  160. Part11.CFrame = CFrame.new(-29.7313805, 0.999997258, -58.6259232, 4.49369422e-21, 7.01608535e-23, -1, -8.6405519e-23, 0.999991775, 7.01614782e-23, 1, 8.64048626e-23, 4.49369422e-21)
  161. Part11.Orientation = Vector3.new(0, -90, 0)
  162. Part11.Position = Vector3.new(-29.7313805, 0.999997258, -58.6259232)
  163. Part11.Rotation = Vector3.new(0, -90, 0)
  164. Part11.Color = Color3.new(0.498039, 0.556863, 0.392157)
  165. Part11.Size = Vector3.new(1, 2, 1)
  166. Part11.BottomSurface = Enum.SurfaceType.Smooth
  167. Part11.BrickColor = BrickColor.new("Grime")
  168. Part11.CanCollide = false
  169. Part11.Material = Enum.Material.SmoothPlastic
  170. Part11.TopSurface = Enum.SurfaceType.Smooth
  171. Part11.brickColor = BrickColor.new("Grime")
  172. Part11.FormFactor = Enum.FormFactor.Symmetric
  173. Part11.formFactor = Enum.FormFactor.Symmetric
  174. Part12.Name = "Left Arm"
  175. Part12.Parent = Model0
  176. Part12.CFrame = CFrame.new(-29.7313805, 2.99998093, -60.6259232, 4.49369422e-21, 7.01608535e-23, -1, -8.6405519e-23, 0.999991775, 7.01614782e-23, 1, 8.64048626e-23, 4.49369422e-21)
  177. Part12.Orientation = Vector3.new(0, -90, 0)
  178. Part12.Position = Vector3.new(-29.7313805, 2.99998093, -60.6259232)
  179. Part12.Rotation = Vector3.new(0, -90, 0)
  180. Part12.Color = Color3.new(1, 0.8, 0.6)
  181. Part12.Size = Vector3.new(1, 2, 1)
  182. Part12.BottomSurface = Enum.SurfaceType.Smooth
  183. Part12.BrickColor = BrickColor.new("Pastel brown")
  184. Part12.CanCollide = false
  185. Part12.Material = Enum.Material.SmoothPlastic
  186. Part12.TopSurface = Enum.SurfaceType.Smooth
  187. Part12.brickColor = BrickColor.new("Pastel brown")
  188. Part12.FormFactor = Enum.FormFactor.Symmetric
  189. Part12.formFactor = Enum.FormFactor.Symmetric
  190. Part13.Name = "Right Arm"
  191. Part13.Parent = Model0
  192. Part13.CFrame = CFrame.new(-29.7313805, 2.99998093, -57.6259232, 4.49369422e-21, 7.01608535e-23, -1, -8.6405519e-23, 0.999991775, 7.01614782e-23, 1, 8.64048626e-23, 4.49369422e-21)
  193. Part13.Orientation = Vector3.new(0, -90, 0)
  194. Part13.Position = Vector3.new(-29.7313805, 2.99998093, -57.6259232)
  195. Part13.Rotation = Vector3.new(0, -90, 0)
  196. Part13.Color = Color3.new(1, 0.8, 0.6)
  197. Part13.Size = Vector3.new(1, 2, 1)
  198. Part13.BottomSurface = Enum.SurfaceType.Smooth
  199. Part13.BrickColor = BrickColor.new("Pastel brown")
  200. Part13.CanCollide = false
  201. Part13.Material = Enum.Material.SmoothPlastic
  202. Part13.TopSurface = Enum.SurfaceType.Smooth
  203. Part13.brickColor = BrickColor.new("Pastel brown")
  204. Part13.FormFactor = Enum.FormFactor.Symmetric
  205. Part13.formFactor = Enum.FormFactor.Symmetric
  206. Part14.Name = "Head"
  207. Part14.Parent = Model0
  208. Part14.CFrame = CFrame.new(-29.7313805, 4.49996853, -59.1259232, 4.49369422e-21, 7.01608598e-23, -1, -8.6405519e-23, 0.999991894, 7.01614782e-23, 1, 8.64048753e-23, 4.49369422e-21)
  209. Part14.Orientation = Vector3.new(0, -90, 0)
  210. Part14.Position = Vector3.new(-29.7313805, 4.49996853, -59.1259232)
  211. Part14.Rotation = Vector3.new(0, -90, 0)
  212. Part14.Color = Color3.new(1, 0.8, 0.6)
  213. Part14.Size = Vector3.new(2, 1, 1)
  214. Part14.BottomSurface = Enum.SurfaceType.Smooth
  215. Part14.BrickColor = BrickColor.new("Pastel brown")
  216. Part14.Material = Enum.Material.SmoothPlastic
  217. Part14.TopSurface = Enum.SurfaceType.Smooth
  218. Part14.brickColor = BrickColor.new("Pastel brown")
  219. Part14.FormFactor = Enum.FormFactor.Symmetric
  220. Part14.formFactor = Enum.FormFactor.Symmetric
  221. SpecialMesh15.Parent = Part14
  222. SpecialMesh15.Scale = Vector3.new(1.25, 1.25, 1.25)
  223. Humanoid16.Parent = Model0
  224. Humanoid16.Health = 500
  225. Humanoid16.LeftLeg = Part10
  226. Humanoid16.MaxHealth = 500
  227. Humanoid16.RightLeg = Part11
  228. Humanoid16.Torso = Part1
  229. Humanoid16.WalkSpeed = 20
  230. Humanoid16.maxHealth = 500
  231. Script17.Name = "Animate"
  232. Script17.Parent = Model0
  233. table.insert(cors,sandbox(Script17,function()
  234. function waitForChild(parent, childName)
  235. local child = parent:findFirstChild(childName)
  236. if child then return child end
  237. while true do
  238. child = parent.ChildAdded:wait()
  239. if child.Name==childName then return child end
  240. end
  241. end
  242.  
  243. local Figure = script.Parent
  244. local Torso = waitForChild(Figure, "Torso")
  245. local RightShoulder = waitForChild(Torso, "Right Shoulder")
  246. local LeftShoulder = waitForChild(Torso, "Left Shoulder")
  247. local RightHip = waitForChild(Torso, "Right Hip")
  248. local LeftHip = waitForChild(Torso, "Left Hip")
  249. local Neck = waitForChild(Torso, "Neck")
  250. local Humanoid = waitForChild(Figure, "Humanoid")
  251. local pose = "Standing"
  252.  
  253. local currentAnim = ""
  254. local currentAnimTrack = nil
  255. local currentAnimKeyframeHandler = nil
  256. local currentAnimSpeed = 1.0
  257. local animTable = {}
  258. local animNames = {
  259. idle = {
  260. { id = "http://www.roblox.com/asset/?id=125750544", weight = 9 },
  261. { id = "http://www.roblox.com/asset/?id=125750618", weight = 1 }
  262. },
  263. walk = {
  264. { id = "http://www.roblox.com/asset/?id=125749145", weight = 10 }
  265. },
  266. run = {
  267. { id = "run.xml", weight = 10 }
  268. },
  269. jump = {
  270. { id = "http://www.roblox.com/asset/?id=125750702", weight = 10 }
  271. },
  272. fall = {
  273. { id = "http://www.roblox.com/asset/?id=125750759", weight = 10 }
  274. },
  275. climb = {
  276. { id = "http://www.roblox.com/asset/?id=125750800", weight = 10 }
  277. },
  278. toolnone = {
  279. { id = "http://www.roblox.com/asset/?id=125750867", weight = 10 }
  280. },
  281. toolslash = {
  282. { id = "http://www.roblox.com/asset/?id=129967390", weight = 10 }
  283. -- { id = "slash.xml", weight = 10 }
  284. },
  285. toollunge = {
  286. { id = "http://www.roblox.com/asset/?id=129967478", weight = 10 }
  287. },
  288. wave = {
  289. { id = "http://www.roblox.com/asset/?id=128777973", weight = 10 }
  290. },
  291. point = {
  292. { id = "http://www.roblox.com/asset/?id=128853357", weight = 10 }
  293. },
  294. dance = {
  295. { id = "http://www.roblox.com/asset/?id=130018893", weight = 10 },
  296. { id = "http://www.roblox.com/asset/?id=132546839", weight = 10 },
  297. { id = "http://www.roblox.com/asset/?id=132546884", weight = 10 }
  298. },
  299. dance2 = {
  300. { id = "http://www.roblox.com/asset/?id=160934142", weight = 10 },
  301. { id = "http://www.roblox.com/asset/?id=160934298", weight = 10 },
  302. { id = "http://www.roblox.com/asset/?id=160934376", weight = 10 }
  303. },
  304. dance3 = {
  305. { id = "http://www.roblox.com/asset/?id=160934458", weight = 10 },
  306. { id = "http://www.roblox.com/asset/?id=160934530", weight = 10 },
  307. { id = "http://www.roblox.com/asset/?id=160934593", weight = 10 }
  308. },
  309. laugh = {
  310. { id = "http://www.roblox.com/asset/?id=129423131", weight = 10 }
  311. },
  312. cheer = {
  313. { id = "http://www.roblox.com/asset/?id=129423030", weight = 10 }
  314. },
  315. }
  316.  
  317. -- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote
  318. local emoteNames = { wave = false, point = false, dance = true, dance2 = true, dance3 = true, laugh = false, cheer = false}
  319.  
  320. math.randomseed(tick())
  321.  
  322. function configureAnimationSet(name, fileList)
  323. if (animTable[name] ~= nil) then
  324. for _, connection in pairs(animTable[name].connections) do
  325. connection:disconnect()
  326. end
  327. end
  328. animTable[name] = {}
  329. animTable[name].count = 0
  330. animTable[name].totalWeight = 0
  331. animTable[name].connections = {}
  332.  
  333. -- check for config values
  334. local config = script:FindFirstChild(name)
  335. if (config ~= nil) then
  336. -- print("Loading anims " .. name)
  337. table.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))
  338. table.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))
  339. local idx = 1
  340. for _, childPart in pairs(config:GetChildren()) do
  341. if (childPart:IsA("Animation")) then
  342. table.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))
  343. animTable[name][idx] = {}
  344. animTable[name][idx].anim = childPart
  345. local weightObject = childPart:FindFirstChild("Weight")
  346. if (weightObject == nil) then
  347. animTable[name][idx].weight = 1
  348. else
  349. animTable[name][idx].weight = weightObject.Value
  350. end
  351. animTable[name].count = animTable[name].count + 1
  352. animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
  353. -- print(name .. " [" .. idx .. "] " .. animTable[name][idx].anim.AnimationId .. " (" .. animTable[name][idx].weight .. ")")
  354. idx = idx + 1
  355. end
  356. end
  357. end
  358.  
  359. -- fallback to defaults
  360. if (animTable[name].count <= 0) then
  361. for idx, anim in pairs(fileList) do
  362. animTable[name][idx] = {}
  363. animTable[name][idx].anim = Instance.new("Animation")
  364. animTable[name][idx].anim.Name = name
  365. animTable[name][idx].anim.AnimationId = anim.id
  366. animTable[name][idx].weight = anim.weight
  367. animTable[name].count = animTable[name].count + 1
  368. animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
  369. -- print(name .. " [" .. idx .. "] " .. anim.id .. " (" .. anim.weight .. ")")
  370. end
  371. end
  372. end
  373.  
  374. -- Setup animation objects
  375. function scriptChildModified(child)
  376. local fileList = animNames[child.Name]
  377. if (fileList ~= nil) then
  378. configureAnimationSet(child.Name, fileList)
  379. end
  380. end
  381.  
  382. script.ChildAdded:connect(scriptChildModified)
  383. script.ChildRemoved:connect(scriptChildModified)
  384.  
  385.  
  386. for name, fileList in pairs(animNames) do
  387. configureAnimationSet(name, fileList)
  388. end
  389.  
  390. -- ANIMATION
  391.  
  392. -- declarations
  393. local toolAnim = "None"
  394. local toolAnimTime = 0
  395.  
  396. local jumpAnimTime = 0
  397. local jumpAnimDuration = 0.3
  398.  
  399. local toolTransitionTime = 0.1
  400. local fallTransitionTime = 0.3
  401. local jumpMaxLimbVelocity = 0.75
  402.  
  403. -- functions
  404.  
  405. function stopAllAnimations()
  406. local oldAnim = currentAnim
  407.  
  408. -- return to idle if finishing an emote
  409. if (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then
  410. oldAnim = "idle"
  411. end
  412.  
  413. currentAnim = ""
  414. if (currentAnimKeyframeHandler ~= nil) then
  415. currentAnimKeyframeHandler:disconnect()
  416. end
  417.  
  418. if (currentAnimTrack ~= nil) then
  419. currentAnimTrack:Stop()
  420. currentAnimTrack:Destroy()
  421. currentAnimTrack = nil
  422. end
  423. return oldAnim
  424. end
  425.  
  426. function setAnimationSpeed(speed)
  427. if speed ~= currentAnimSpeed then
  428. currentAnimSpeed = speed
  429. currentAnimTrack:AdjustSpeed(currentAnimSpeed)
  430. end
  431. end
  432.  
  433. function keyFrameReachedFunc(frameName)
  434. if (frameName == "End") then
  435. -- print("Keyframe : ".. frameName)
  436. local repeatAnim = stopAllAnimations()
  437. local animSpeed = currentAnimSpeed
  438. playAnimation(repeatAnim, 0.0, Humanoid)
  439. setAnimationSpeed(animSpeed)
  440. end
  441. end
  442.  
  443. -- Preload animations
  444. function playAnimation(animName, transitionTime, humanoid)
  445. local idleFromEmote = (animName == "idle" and emoteNames[currentAnim] ~= nil)
  446. if (animName ~= currentAnim and not idleFromEmote) then
  447.  
  448. if (currentAnimTrack ~= nil) then
  449. currentAnimTrack:Stop(transitionTime)
  450. currentAnimTrack:Destroy()
  451. end
  452.  
  453. currentAnimSpeed = 1.0
  454. local roll = math.random(1, animTable[animName].totalWeight)
  455. local origRoll = roll
  456. local idx = 1
  457. while (roll > animTable[animName][idx].weight) do
  458. roll = roll - animTable[animName][idx].weight
  459. idx = idx + 1
  460. end
  461. -- print(animName .. " " .. idx .. " [" .. origRoll .. "]")
  462. local anim = animTable[animName][idx].anim
  463.  
  464. -- load it to the humanoid; get AnimationTrack
  465. currentAnimTrack = humanoid:LoadAnimation(anim)
  466.  
  467. -- play the animation
  468. currentAnimTrack:Play(transitionTime)
  469. currentAnim = animName
  470.  
  471. -- set up keyframe name triggers
  472. if (currentAnimKeyframeHandler ~= nil) then
  473. currentAnimKeyframeHandler:disconnect()
  474. end
  475. currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
  476. end
  477. end
  478.  
  479. -------------------------------------------------------------------------------------------
  480. -------------------------------------------------------------------------------------------
  481.  
  482. local toolAnimName = ""
  483. local toolAnimTrack = nil
  484. local currentToolAnimKeyframeHandler = nil
  485.  
  486. function toolKeyFrameReachedFunc(frameName)
  487. if (frameName == "End") then
  488. -- print("Keyframe : ".. frameName)
  489. local repeatAnim = stopToolAnimations()
  490. playToolAnimation(repeatAnim, 0.0, Humanoid)
  491. end
  492. end
  493.  
  494.  
  495. function playToolAnimation(animName, transitionTime, humanoid)
  496. if (animName ~= toolAnimName) then
  497.  
  498. if (toolAnimTrack ~= nil) then
  499. toolAnimTrack:Stop()
  500. toolAnimTrack:Destroy()
  501. transitionTime = 0
  502. end
  503.  
  504. local roll = math.random(1, animTable[animName].totalWeight)
  505. local origRoll = roll
  506. local idx = 1
  507. while (roll > animTable[animName][idx].weight) do
  508. roll = roll - animTable[animName][idx].weight
  509. idx = idx + 1
  510. end
  511. -- print(animName .. " * " .. idx .. " [" .. origRoll .. "]")
  512. local anim = animTable[animName][idx].anim
  513.  
  514. -- load it to the humanoid; get AnimationTrack
  515. toolAnimTrack = humanoid:LoadAnimation(anim)
  516.  
  517. -- play the animation
  518. toolAnimTrack:Play(transitionTime)
  519. toolAnimName = animName
  520.  
  521. currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
  522. end
  523. end
  524.  
  525. function stopToolAnimations()
  526. local oldAnim = toolAnimName
  527.  
  528. if (currentToolAnimKeyframeHandler ~= nil) then
  529. currentToolAnimKeyframeHandler:disconnect()
  530. end
  531.  
  532. toolAnimName = ""
  533. if (toolAnimTrack ~= nil) then
  534. toolAnimTrack:Stop()
  535. toolAnimTrack:Destroy()
  536. toolAnimTrack = nil
  537. end
  538.  
  539.  
  540. return oldAnim
  541. end
  542.  
  543. -------------------------------------------------------------------------------------------
  544. -------------------------------------------------------------------------------------------
  545.  
  546.  
  547. function onRunning(speed)
  548. if speed>0.01 then
  549. playAnimation("walk", 0.1, Humanoid)
  550. pose = "Running"
  551. else
  552. playAnimation("idle", 0.1, Humanoid)
  553. pose = "Standing"
  554. end
  555. end
  556.  
  557. function onDied()
  558. pose = "Dead"
  559. end
  560.  
  561. function onJumping()
  562. playAnimation("jump", 0.1, Humanoid)
  563. jumpAnimTime = jumpAnimDuration
  564. pose = "Jumping"
  565. end
  566.  
  567. function onClimbing(speed)
  568. playAnimation("climb", 0.1, Humanoid)
  569. setAnimationSpeed(speed / 12.0)
  570. pose = "Climbing"
  571. end
  572.  
  573. function onGettingUp()
  574. pose = "GettingUp"
  575. end
  576.  
  577. function onFreeFall()
  578. if (jumpAnimTime <= 0) then
  579. playAnimation("fall", fallTransitionTime, Humanoid)
  580. end
  581. pose = "FreeFall"
  582. end
  583.  
  584. function onFallingDown()
  585. pose = "FallingDown"
  586. end
  587.  
  588. function onSeated()
  589. pose = "Seated"
  590. end
  591.  
  592. function onPlatformStanding()
  593. pose = "PlatformStanding"
  594. end
  595.  
  596. function onSwimming(speed)
  597. if speed>0 then
  598. pose = "Running"
  599. else
  600. pose = "Standing"
  601. end
  602. end
  603.  
  604. function getTool()
  605. for _, kid in ipairs(Figure:GetChildren()) do
  606. if kid.className == "Tool" then return kid end
  607. end
  608. return nil
  609. end
  610.  
  611. function getToolAnim(tool)
  612. for _, c in ipairs(tool:GetChildren()) do
  613. if c.Name == "toolanim" and c.className == "StringValue" then
  614. return c
  615. end
  616. end
  617. return nil
  618. end
  619.  
  620. function animateTool()
  621.  
  622. if (toolAnim == "None") then
  623. playToolAnimation("toolnone", toolTransitionTime, Humanoid)
  624. return
  625. end
  626.  
  627. if (toolAnim == "Slash") then
  628. playToolAnimation("toolslash", 0, Humanoid)
  629. return
  630. end
  631.  
  632. if (toolAnim == "Lunge") then
  633. playToolAnimation("toollunge", 0, Humanoid)
  634. return
  635. end
  636. end
  637.  
  638. function moveSit()
  639. RightShoulder.MaxVelocity = 0.15
  640. LeftShoulder.MaxVelocity = 0.15
  641. RightShoulder:SetDesiredAngle(3.14 /2)
  642. LeftShoulder:SetDesiredAngle(-3.14 /2)
  643. RightHip:SetDesiredAngle(3.14 /2)
  644. LeftHip:SetDesiredAngle(-3.14 /2)
  645. end
  646.  
  647. local lastTick = 0
  648.  
  649. function move(time)
  650. local amplitude = 1
  651. local frequency = 1
  652. local deltaTime = time - lastTick
  653. lastTick = time
  654.  
  655. local climbFudge = 0
  656. local setAngles = false
  657.  
  658. if (jumpAnimTime > 0) then
  659. jumpAnimTime = jumpAnimTime - deltaTime
  660. end
  661.  
  662. if (pose == "FreeFall" and jumpAnimTime <= 0) then
  663. playAnimation("fall", fallTransitionTime, Humanoid)
  664. elseif (pose == "Seated") then
  665. stopAllAnimations()
  666. moveSit()
  667. return
  668. elseif (pose == "Running") then
  669. playAnimation("walk", 0.1, Humanoid)
  670. elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then
  671. -- print("Wha " .. pose)
  672. amplitude = 0.1
  673. frequency = 1
  674. setAngles = true
  675. end
  676.  
  677. if (setAngles) then
  678. desiredAngle = amplitude * math.sin(time * frequency)
  679.  
  680. RightShoulder:SetDesiredAngle(desiredAngle + climbFudge)
  681. LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
  682. RightHip:SetDesiredAngle(-desiredAngle)
  683. LeftHip:SetDesiredAngle(-desiredAngle)
  684. end
  685.  
  686. -- Tool Animation handling
  687. local tool = getTool()
  688. if tool then
  689.  
  690. animStringValueObject = getToolAnim(tool)
  691.  
  692. if animStringValueObject then
  693. toolAnim = animStringValueObject.Value
  694. -- message recieved, delete StringValue
  695. animStringValueObject.Parent = nil
  696. toolAnimTime = time + .3
  697. end
  698.  
  699. if time > toolAnimTime then
  700. toolAnimTime = 0
  701. toolAnim = "None"
  702. end
  703.  
  704. animateTool()
  705. else
  706. stopToolAnimations()
  707. toolAnim = "None"
  708. toolAnimTime = 0
  709. end
  710. end
  711.  
  712. -- connect events
  713. Humanoid.Died:connect(onDied)
  714. Humanoid.Running:connect(onRunning)
  715. Humanoid.Jumping:connect(onJumping)
  716. Humanoid.Climbing:connect(onClimbing)
  717. Humanoid.GettingUp:connect(onGettingUp)
  718. Humanoid.FreeFalling:connect(onFreeFall)
  719. Humanoid.FallingDown:connect(onFallingDown)
  720. Humanoid.Seated:connect(onSeated)
  721. Humanoid.PlatformStanding:connect(onPlatformStanding)
  722. Humanoid.Swimming:connect(onSwimming)
  723.  
  724. -- main program
  725.  
  726. local runService = game:service("RunService");
  727.  
  728. -- initialize to idle
  729. playAnimation("idle", 0.1, Humanoid)
  730. pose = "Standing"
  731.  
  732. while Figure.Parent~=nil do
  733. local _, time = wait(0.1)
  734. move(time)
  735. end
  736.  
  737.  
  738.  
  739. end))
  740. StringValue18.Name = "climb"
  741. StringValue18.Parent = Script17
  742. Animation19.Name = "ClimbAnim"
  743. Animation19.Parent = StringValue18
  744. Animation19.AnimationId = "http://www.roblox.com/asset/?id=125750800"
  745. StringValue20.Name = "fall"
  746. StringValue20.Parent = Script17
  747. Animation21.Name = "FallAnim"
  748. Animation21.Parent = StringValue20
  749. Animation21.AnimationId = "rbxassetid://399379775"
  750. StringValue22.Name = "idle"
  751. StringValue22.Parent = Script17
  752. Animation23.Name = "Animation1"
  753. Animation23.Parent = StringValue22
  754. Animation23.AnimationId = "rbxassetid://396524805"
  755. NumberValue24.Name = "Weight"
  756. NumberValue24.Parent = Animation23
  757. NumberValue24.Value = 9
  758. Animation25.Name = "Animation2"
  759. Animation25.Parent = StringValue22
  760. Animation25.AnimationId = "rbxassetid://396524805"
  761. NumberValue26.Name = "Weight"
  762. NumberValue26.Parent = Animation25
  763. NumberValue26.Value = 1
  764. StringValue27.Name = "jump"
  765. StringValue27.Parent = Script17
  766. Animation28.Name = "JumpAnim"
  767. Animation28.Parent = StringValue27
  768. Animation28.AnimationId = "rbxassetid://399378534"
  769. StringValue29.Name = "run"
  770. StringValue29.Parent = Script17
  771. Animation30.Name = "RunAnim"
  772. Animation30.Parent = StringValue29
  773. Animation30.AnimationId = "rbxassetid://399377124"
  774. StringValue31.Name = "toolnone"
  775. StringValue31.Parent = Script17
  776. Animation32.Name = "ToolNoneAnim"
  777. Animation32.Parent = StringValue31
  778. Animation32.AnimationId = "http://www.roblox.com/asset/?id=125750867"
  779. StringValue33.Name = "walk"
  780. StringValue33.Parent = Script17
  781. Animation34.Name = "WalkAnim"
  782. Animation34.Parent = StringValue33
  783. Animation34.AnimationId = "rbxassetid://399377124"
  784. BodyColors35.Parent = nil
  785. BodyColors35.HeadColor = BrickColor.new("Medium stone grey")
  786. BodyColors35.HeadColor3 = Color3.new(0.639216, 0.635294, 0.647059)
  787. BodyColors35.LeftArmColor = BrickColor.new("Medium stone grey")
  788. BodyColors35.LeftArmColor3 = Color3.new(0.639216, 0.635294, 0.647059)
  789. BodyColors35.LeftLegColor = BrickColor.new("Medium stone grey")
  790. BodyColors35.LeftLegColor3 = Color3.new(0.639216, 0.635294, 0.647059)
  791. BodyColors35.RightArmColor = BrickColor.new("Medium stone grey")
  792. BodyColors35.RightArmColor3 = Color3.new(0.639216, 0.635294, 0.647059)
  793. BodyColors35.RightLegColor = BrickColor.new("Medium stone grey")
  794. BodyColors35.RightLegColor3 = Color3.new(0.639216, 0.635294, 0.647059)
  795. BodyColors35.TorsoColor = BrickColor.new("Medium stone grey")
  796. BodyColors35.TorsoColor3 = Color3.new(0.639216, 0.635294, 0.647059)
  797. Script36.Name = "Respawn"
  798. Script36.Parent = Model0
  799. table.insert(cors,sandbox(Script36,function()
  800. name="Humanoid"
  801.  
  802.  
  803.  
  804. robo=script.Parent:clone()
  805.  
  806.  
  807.  
  808. while true do
  809.  
  810. wait(5)
  811.  
  812. if script.Parent.Humanoid.Health<1 then
  813.  
  814. robot=robo:clone()
  815.  
  816. robot.Parent=script.Parent.Parent
  817.  
  818. robot:makeJoints()
  819.  
  820. script.Parent:remove()
  821.  
  822. end
  823.  
  824. end
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833. end))
  834. Shirt37.Name = "Shirt"
  835. Shirt37.Parent = Model0
  836. Pants38.Name = "Pants"
  837. Pants38.Parent = Model0
  838. for i,v in pairs(mas:GetChildren()) do
  839. v.Parent = script
  840. pcall(function() v:MakeJoints() end)
  841. end
  842. mas:Destroy()
  843. for i,v in pairs(cors) do
  844. spawn(function()
  845. pcall(v)
  846. end)
  847. end
  848.  
  849. Model0.Torso.CFrame = owner.Character.Torso.CFrame
  850.  
  851. while true do
  852. wait()
  853. Humanoid16.WalkToPoint = owner.Character.Torso.Position
  854. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement