Advertisement
LOl2x234

Untitled

Feb 5th, 2018
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.47 KB | None | 0 0
  1.  
  2. local runDummyScript = function(f,scri)
  3. local oldenv = getfenv(f)
  4. local newenv = setmetatable({}, {
  5. __index = function(_, k)
  6. if k:lower() == 'script' then
  7. return scri
  8. else
  9. return oldenv[k]
  10. end
  11. end
  12. })
  13. setfenv(f, newenv)
  14. ypcall(function() f() end)
  15. end
  16. cors = {}
  17. mas = Instance.new("Model",game:GetService("Lighting"))
  18. mas.Name = "CompiledModel"
  19. o1 = Instance.new("Sound")
  20. o2 = Instance.new("Sound")
  21. o3 = Instance.new("Sound")
  22. o4 = Instance.new("Sound")
  23. o5 = Instance.new("Sound")
  24. o6 = Instance.new("Sound")
  25. o7 = Instance.new("Script")
  26. o8 = Instance.new("Model")
  27. o9 = Instance.new("Part")
  28. o10 = Instance.new("Motor6D")
  29. o11 = Instance.new("Part")
  30. o12 = Instance.new("Motor6D")
  31. o13 = Instance.new("Motor6D")
  32. o14 = Instance.new("Motor6D")
  33. o15 = Instance.new("Motor6D")
  34. o16 = Instance.new("Motor6D")
  35. o17 = Instance.new("Part")
  36. o18 = Instance.new("Part")
  37. o19 = Instance.new("Part")
  38. o20 = Instance.new("Part")
  39. o21 = Instance.new("Part")
  40. o22 = Instance.new("SpecialMesh")
  41. o23 = Instance.new("Decal")
  42. o24 = Instance.new("Decal")
  43. o25 = Instance.new("Humanoid")
  44. o26 = Instance.new("CharacterMesh")
  45. o27 = Instance.new("CharacterMesh")
  46. o28 = Instance.new("CharacterMesh")
  47. o29 = Instance.new("CharacterMesh")
  48. o30 = Instance.new("CharacterMesh")
  49. o31 = Instance.new("Script")
  50. o32 = Instance.new("Script")
  51. o33 = Instance.new("StringValue")
  52. o34 = Instance.new("Animation")
  53. o35 = Instance.new("StringValue")
  54. o36 = Instance.new("Animation")
  55. o37 = Instance.new("StringValue")
  56. o38 = Instance.new("Animation")
  57. o39 = Instance.new("NumberValue")
  58. o40 = Instance.new("Animation")
  59. o41 = Instance.new("NumberValue")
  60. o42 = Instance.new("StringValue")
  61. o43 = Instance.new("Animation")
  62. o44 = Instance.new("StringValue")
  63. o45 = Instance.new("Animation")
  64. o46 = Instance.new("StringValue")
  65. o47 = Instance.new("Animation")
  66. o48 = Instance.new("StringValue")
  67. o49 = Instance.new("Animation")
  68. o50 = Instance.new("StringValue")
  69. o51 = Instance.new("Animation")
  70. o1.Name = "Gore"
  71. o1.Parent = mas
  72. o1.SoundId = "rbxassetid://429400881"
  73. o2.Name = "GoreTwo"
  74. o2.Parent = mas
  75. o2.SoundId = "rbxassetid://356551938"
  76. o3.Name = "Stab"
  77. o3.Parent = mas
  78. o3.SoundId = "rbxassetid://1386772138"
  79. o4.Name = "StabTwo"
  80. o4.Parent = mas
  81. o4.SoundId = "rbxassetid://186311262"
  82. o4.Volume = 10
  83. o5.Name = "Static"
  84. o5.Parent = mas
  85. o5.SoundId = "rbxassetid://172906410"
  86. o6.Name = "Theme"
  87. o6.Parent = mas
  88. o6.SoundId = "rbxassetid://190630557"
  89. o7.Parent = mas
  90. table.insert(cors,coroutine.create(function()
  91. wait()
  92. runDummyScript(function()
  93.  
  94. game.Workspace.Theme:Play()
  95. game.Workspace.Static:Play()
  96. game.Workspace.Theme.Looped = true
  97. game.Workspace.Static.Looped = true
  98. wait(19)
  99. game.Workspace.RUST_010.Head.Smiley.Transparency = (1)
  100. game.Workspace.RUST_010.Head.Creepy.Transparency = (0)
  101. game.Workspace.RUST_010.Humanoid.DisplayDistanceType = ("None")
  102. wait(9)
  103. game.Workspace.Stab:Play()
  104. wait(2)
  105. game.Workspace.Gore:Play()
  106. wait(0.7)
  107. game.Workspace.StabTwo:Play()
  108. wait(1)
  109. game.Workspace.GoreTwo:Play()
  110. wait(0.4)
  111. game.Workspace.Gore:Play()
  112.  
  113. getplayers = game.Players:GetChildren()
  114. for a=1, #getplayers do
  115. wait(0.01)
  116. char = getplayers[a].Character
  117. char.Humanoid.Health = 0
  118. end
  119. wait(1)
  120.  
  121. cce = Instance.new("ColorCorrectionEffect",game.Lighting)
  122. cce.Brightness = 0
  123. cce.Brightness = cce.Brightness - 1
  124.  
  125.  
  126. dark()
  127. dark()
  128. dark()
  129. dark()
  130. end,o7)
  131. end))
  132. o8.Name = "RUST_010"
  133. o8.Parent = mas
  134. o8.PrimaryPart = o9
  135. o9.Name = "HumanoidRootPart"
  136. o9.Parent = o8
  137. o9.BrickColor = BrickColor.new("Institutional white")
  138. o9.Transparency = 1
  139. o9.Position = Vector3.new(4.69998121, 3.36031294, -1.50085402)
  140. o9.Size = Vector3.new(2, 2, 1)
  141. o9.CFrame = CFrame.new(-4.53571987, 3.00000191, 13.2005901, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  142. o9.BottomSurface = Enum.SurfaceType.Smooth
  143. o9.TopSurface = Enum.SurfaceType.Smooth
  144. o9.Color = Color3.new(0.972549, 0.972549, 0.972549)
  145. o9.Position = Vector3.new(-4.53571987, 3.00000191, 13.2005901)
  146. o10.Name = "Root Hip"
  147. o10.Parent = o9
  148. o10.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  149. o10.C1 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  150. o10.Part0 = o9
  151. o10.Part1 = o11
  152. o10.MaxVelocity = 0.10000000149012
  153. o11.Name = "Torso"
  154. o11.Parent = o8
  155. o11.BrickColor = BrickColor.new("Dark green")
  156. o11.Position = Vector3.new(-4.53571987, 3.00000191, 13.2005901)
  157. o11.CanCollide = false
  158. o11.Size = Vector3.new(2, 2, 1)
  159. o11.CFrame = CFrame.new(-4.53571987, 3.00000191, 13.2005901, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  160. o11.BottomSurface = Enum.SurfaceType.Smooth
  161. o11.TopSurface = Enum.SurfaceType.Smooth
  162. o11.Color = Color3.new(0.156863, 0.498039, 0.278431)
  163. o11.Position = Vector3.new(-4.53571987, 3.00000191, 13.2005901)
  164. o12.Name = "Left Hip"
  165. o12.Parent = o11
  166. o12.C0 = CFrame.new(-1, -1, 0, -4.37113883e-08, 0, -1, 0, 0.99999994, 0, 1, 0, -4.37113883e-08)
  167. o12.C1 = CFrame.new(-0.5, 1, 0, -4.37113883e-08, 0, -1, 0, 0.99999994, 0, 1, 0, -4.37113883e-08)
  168. o12.Part0 = o11
  169. o12.Part1 = o17
  170. o12.MaxVelocity = 0.10000000149012
  171. o13.Name = "Right Hip"
  172. o13.Parent = o11
  173. o13.C0 = CFrame.new(1, -1, 0, -4.37113883e-08, 0, 1, -0, 0.99999994, 0, -1, 0, -4.37113883e-08)
  174. o13.C1 = CFrame.new(0.5, 1, 0, -4.37113883e-08, 0, 1, 0, 0.99999994, 0, -1, 0, -4.37113883e-08)
  175. o13.Part0 = o11
  176. o13.Part1 = o18
  177. o13.MaxVelocity = 0.10000000149012
  178. o14.Name = "Left Shoulder"
  179. o14.Parent = o11
  180. o14.C0 = CFrame.new(-1, 0.5, 0, -4.37113883e-08, 0, -1, 0, 0.99999994, 0, 1, 0, -4.37113883e-08)
  181. o14.C1 = CFrame.new(0.5, 0.5, 0, -4.37113883e-08, 0, -1, 0, 0.99999994, 0, 1, 0, -4.37113883e-08)
  182. o14.Part0 = o11
  183. o14.Part1 = o19
  184. o14.MaxVelocity = 0.10000000149012
  185. o15.Name = "Right Shoulder"
  186. o15.Parent = o11
  187. o15.C0 = CFrame.new(1, 0.5, 0, -4.37113883e-08, 0, 1, -0, 0.99999994, 0, -1, 0, -4.37113883e-08)
  188. o15.C1 = CFrame.new(-0.5, 0.5, 0, -4.37113883e-08, 0, 1, 0, 0.99999994, 0, -1, 0, -4.37113883e-08)
  189. o15.Part0 = o11
  190. o15.Part1 = o20
  191. o15.MaxVelocity = 0.10000000149012
  192. o16.Name = "Neck"
  193. o16.Parent = o11
  194. o16.C0 = CFrame.new(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  195. o16.C1 = CFrame.new(0, -0.5, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  196. o16.Part0 = o11
  197. o16.Part1 = o21
  198. o16.MaxVelocity = 0.10000000149012
  199. o17.Name = "Left Leg"
  200. o17.Parent = o8
  201. o17.Position = Vector3.new(-5.03571987, 1.00000203, 13.2005901)
  202. o17.CanCollide = false
  203. o17.Size = Vector3.new(1, 2, 1)
  204. o17.CFrame = CFrame.new(-5.03571987, 1.00000203, 13.2005901, 1, 0, 0, 0, 0.999999881, 0, 0, 0, 1)
  205. o17.BottomSurface = Enum.SurfaceType.Smooth
  206. o17.TopSurface = Enum.SurfaceType.Smooth
  207. o17.Position = Vector3.new(-5.03571987, 1.00000203, 13.2005901)
  208. o18.Name = "Right Leg"
  209. o18.Parent = o8
  210. o18.Position = Vector3.new(-4.03571987, 1.00000203, 13.2005901)
  211. o18.CanCollide = false
  212. o18.Size = Vector3.new(1, 2, 1)
  213. o18.CFrame = CFrame.new(-4.03571987, 1.00000203, 13.2005901, 1, 0, 0, 0, 0.999999881, 0, 0, 0, 1)
  214. o18.BottomSurface = Enum.SurfaceType.Smooth
  215. o18.TopSurface = Enum.SurfaceType.Smooth
  216. o18.Position = Vector3.new(-4.03571987, 1.00000203, 13.2005901)
  217. o19.Name = "Left Arm"
  218. o19.Parent = o8
  219. o19.BrickColor = BrickColor.new("Institutional white")
  220. o19.Position = Vector3.new(-6.03571987, 3.00000191, 13.2005901)
  221. o19.CanCollide = false
  222. o19.Size = Vector3.new(1, 2, 1)
  223. o19.CFrame = CFrame.new(-6.03571987, 3.00000191, 13.2005901, 1, 0, 0, 0, 0.999999881, 0, 0, 0, 1)
  224. o19.BottomSurface = Enum.SurfaceType.Smooth
  225. o19.TopSurface = Enum.SurfaceType.Smooth
  226. o19.Color = Color3.new(0.972549, 0.972549, 0.972549)
  227. o19.Position = Vector3.new(-6.03571987, 3.00000191, 13.2005901)
  228. o20.Name = "Right Arm"
  229. o20.Parent = o8
  230. o20.BrickColor = BrickColor.new("Institutional white")
  231. o20.Position = Vector3.new(-3.03571987, 3.00000191, 13.2005901)
  232. o20.CanCollide = false
  233. o20.Size = Vector3.new(1, 2, 1)
  234. o20.CFrame = CFrame.new(-3.03571987, 3.00000191, 13.2005901, 1, 0, 0, 0, 0.999999881, 0, 0, 0, 1)
  235. o20.BottomSurface = Enum.SurfaceType.Smooth
  236. o20.TopSurface = Enum.SurfaceType.Smooth
  237. o20.Color = Color3.new(0.972549, 0.972549, 0.972549)
  238. o20.Position = Vector3.new(-3.03571987, 3.00000191, 13.2005901)
  239. o21.Name = "Head"
  240. o21.Parent = o8
  241. o21.BrickColor = BrickColor.new("Institutional white")
  242. o21.Position = Vector3.new(-4.53571987, 4.50000191, 13.2005901)
  243. o21.Size = Vector3.new(2, 1, 1)
  244. o21.CFrame = CFrame.new(-4.53571987, 4.50000191, 13.2005901, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  245. o21.BottomSurface = Enum.SurfaceType.Smooth
  246. o21.TopSurface = Enum.SurfaceType.Smooth
  247. o21.Color = Color3.new(0.972549, 0.972549, 0.972549)
  248. o21.Position = Vector3.new(-4.53571987, 4.50000191, 13.2005901)
  249. o22.Parent = o21
  250. o22.MeshId = "http://www.roblox.com/asset/?id=83001675"
  251. o22.Scale = Vector3.new(1.25, 1.25, 1.25)
  252. o22.MeshType = Enum.MeshType.FileMesh
  253. o23.Name = "Smiley"
  254. o23.Parent = o21
  255. o23.Texture = "http://www.roblox.com/asset/?id=173083239"
  256. o24.Name = "Creepy"
  257. o24.Parent = o21
  258. o24.Transparency = 1
  259. o24.Texture = "http://www.roblox.com/asset/?id=1302590244"
  260. o25.Parent = o8
  261. o25.RightLeg = o18
  262. o25.LeftLeg = o17
  263. o25.Torso = o9
  264. o26.Parent = o8
  265. o26.MeshId = 82908019
  266. o26.BodyPart = Enum.BodyPart.RightArm
  267. o27.Parent = o8
  268. o27.MeshId = 82907977
  269. o27.BodyPart = Enum.BodyPart.LeftArm
  270. o28.Parent = o8
  271. o28.MeshId = 82907945
  272. o28.BodyPart = Enum.BodyPart.Torso
  273. o29.Parent = o8
  274. o29.MeshId = 81487710
  275. o29.BodyPart = Enum.BodyPart.RightLeg
  276. o30.Parent = o8
  277. o30.MeshId = 81487640
  278. o30.BodyPart = Enum.BodyPart.LeftLeg
  279. o31.Name = "Move"
  280. o31.Parent = o8
  281. table.insert(cors,coroutine.create(function()
  282. wait()
  283. runDummyScript(function()
  284. local CurrentPart = nil
  285. local MaxInc = 16
  286.  
  287. function onTouched(hit)
  288. if hit.Parent == nil then
  289. return
  290. end
  291.  
  292. local humanoid = hit.Parent:findFirstChild("Humanoid")
  293.  
  294. if humanoid == nil then
  295. CurrentPart = hit
  296. end
  297. end
  298.  
  299. function waitForChild(parent, childName)
  300. local child = parent:findFirstChild(childName)
  301.  
  302. if child then
  303. return child
  304. end
  305.  
  306. while true do
  307. print(childName)
  308.  
  309. child = parent.ChildAdded:wait()
  310.  
  311. if child.Name==childName then
  312. return child
  313. end
  314. end
  315. end
  316.  
  317. local Figure = script.Parent
  318. local Humanoid = waitForChild(Figure, "Humanoid")
  319. local Torso = waitForChild(Figure, "Torso")
  320. local Left = waitForChild(Figure, "Left Leg")
  321. local Right = waitForChild(Figure, "Right Leg")
  322.  
  323. Humanoid.Jump = true
  324.  
  325. Left.Touched:connect(onTouched)
  326. Right.Touched:connect(onTouched)
  327.  
  328. while true do
  329. wait(math.random(0.001, 3))
  330.  
  331. if CurrentPart ~= nil then
  332. if math.random(1, 2) == 1 then
  333. Humanoid.Jump = true
  334. end
  335.  
  336. Humanoid:MoveTo(Torso.Position + Vector3.new(math.random(-MaxInc, MaxInc), 0, math.random(-MaxInc, MaxInc)), CurrentPart)
  337. end
  338. end
  339. end,o31)
  340. end))
  341. o32.Name = "Animate"
  342. o32.Parent = o8
  343. table.insert(cors,coroutine.create(function()
  344. wait()
  345. runDummyScript(function()
  346. function waitForChild(parent, childName)
  347. local child = parent:findFirstChild(childName)
  348. if child then return child end
  349. while true do
  350. child = parent.ChildAdded:wait()
  351. if child.Name==childName then return child end
  352. end
  353. end
  354.  
  355. local Figure = script.Parent
  356. local Torso = waitForChild(Figure, "Torso")
  357. local RightShoulder = waitForChild(Torso, "Right Shoulder")
  358. local LeftShoulder = waitForChild(Torso, "Left Shoulder")
  359. local RightHip = waitForChild(Torso, "Right Hip")
  360. local LeftHip = waitForChild(Torso, "Left Hip")
  361. local Neck = waitForChild(Torso, "Neck")
  362. local Humanoid = waitForChild(Figure, "Humanoid")
  363. local pose = "Standing"
  364.  
  365. local currentAnim = ""
  366. local currentAnimTrack = nil
  367. local currentAnimKeyframeHandler = nil
  368. local oldAnimTrack = nil
  369. local animTable = {}
  370. local animNames = {
  371. idle = {
  372. { id = "http://www.roblox.com/asset/?id=180435571", weight = 9 },
  373. { id = "http://www.roblox.com/asset/?id=180435792", weight = 1 }
  374. },
  375. walk = {
  376. { id = "http://www.roblox.com/asset/?id=180426354", weight = 10 }
  377. },
  378. run = {
  379. { id = "run.xml", weight = 10 }
  380. },
  381. jump = {
  382. { id = "http://www.roblox.com/asset/?id=125750702", weight = 10 }
  383. },
  384. fall = {
  385. { id = "http://www.roblox.com/asset/?id=180436148", weight = 10 }
  386. },
  387. climb = {
  388. { id = "http://www.roblox.com/asset/?id=180436334", weight = 10 }
  389. },
  390. sit = {
  391. { id = "http://www.roblox.com/asset/?id=178130996", weight = 10 }
  392. },
  393. toolnone = {
  394. { id = "http://www.roblox.com/asset/?id=182393478", weight = 10 }
  395. },
  396. toolslash = {
  397. { id = "http://www.roblox.com/asset/?id=129967390", weight = 10 }
  398. -- { id = "slash.xml", weight = 10 }
  399. },
  400. toollunge = {
  401. { id = "http://www.roblox.com/asset/?id=129967478", weight = 10 }
  402. },
  403. wave = {
  404. { id = "http://www.roblox.com/asset/?id=128777973", weight = 10 }
  405. },
  406. point = {
  407. { id = "http://www.roblox.com/asset/?id=128853357", weight = 10 }
  408. },
  409. dance = {
  410. { id = "http://www.roblox.com/asset/?id=182435998", weight = 10 },
  411. { id = "http://www.roblox.com/asset/?id=182491037", weight = 10 },
  412. { id = "http://www.roblox.com/asset/?id=182491065", weight = 10 }
  413. },
  414. dance2 = {
  415. { id = "http://www.roblox.com/asset/?id=182436842", weight = 10 },
  416. { id = "http://www.roblox.com/asset/?id=182491248", weight = 10 },
  417. { id = "http://www.roblox.com/asset/?id=182491277", weight = 10 }
  418. },
  419. dance3 = {
  420. { id = "http://www.roblox.com/asset/?id=182436935", weight = 10 },
  421. { id = "http://www.roblox.com/asset/?id=182491368", weight = 10 },
  422. { id = "http://www.roblox.com/asset/?id=182491423", weight = 10 }
  423. },
  424. laugh = {
  425. { id = "http://www.roblox.com/asset/?id=129423131", weight = 10 }
  426. },
  427. cheer = {
  428. { id = "http://www.roblox.com/asset/?id=129423030", weight = 10 }
  429. },
  430. }
  431.  
  432. -- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote
  433. local emoteNames = { wave = false, point = false, dance = true, dance2 = true, dance3 = true, laugh = false, cheer = false}
  434.  
  435. math.randomseed(tick())
  436.  
  437. function configureAnimationSet(name, fileList)
  438. if (animTable[name] ~= nil) then
  439. for _, connection in pairs(animTable[name].connections) do
  440. connection:disconnect()
  441. end
  442. end
  443. animTable[name] = {}
  444. animTable[name].count = 0
  445. animTable[name].totalWeight = 0
  446. animTable[name].connections = {}
  447.  
  448. -- check for config values
  449. local config = script:FindFirstChild(name)
  450. if (config ~= nil) then
  451. -- print("Loading anims " .. name)
  452. table.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))
  453. table.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))
  454. local idx = 1
  455. for _, childPart in pairs(config:GetChildren()) do
  456. if (childPart:IsA("Animation")) then
  457. table.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))
  458. animTable[name][idx] = {}
  459. animTable[name][idx].anim = childPart
  460. local weightObject = childPart:FindFirstChild("Weight")
  461. if (weightObject == nil) then
  462. animTable[name][idx].weight = 1
  463. else
  464. animTable[name][idx].weight = weightObject.Value
  465. end
  466. animTable[name].count = animTable[name].count + 1
  467. animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
  468. -- print(name .. " [" .. idx .. "] " .. animTable[name][idx].anim.AnimationId .. " (" .. animTable[name][idx].weight .. ")")
  469. idx = idx + 1
  470. end
  471. end
  472. end
  473.  
  474. -- fallback to defaults
  475. if (animTable[name].count <= 0) then
  476. for idx, anim in pairs(fileList) do
  477. animTable[name][idx] = {}
  478. animTable[name][idx].anim = Instance.new("Animation")
  479. animTable[name][idx].anim.Name = name
  480. animTable[name][idx].anim.AnimationId = anim.id
  481. animTable[name][idx].weight = anim.weight
  482. animTable[name].count = animTable[name].count + 1
  483. animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
  484. -- print(name .. " [" .. idx .. "] " .. anim.id .. " (" .. anim.weight .. ")")
  485. end
  486. end
  487. end
  488.  
  489. -- Setup animation objects
  490. function scriptChildModified(child)
  491. local fileList = animNames[child.Name]
  492. if (fileList ~= nil) then
  493. configureAnimationSet(child.Name, fileList)
  494. end
  495. end
  496.  
  497. script.ChildAdded:connect(scriptChildModified)
  498. script.ChildRemoved:connect(scriptChildModified)
  499.  
  500.  
  501. for name, fileList in pairs(animNames) do
  502. configureAnimationSet(name, fileList)
  503. end
  504.  
  505. -- ANIMATION
  506.  
  507. -- declarations
  508. local toolAnim = "None"
  509. local toolAnimTime = 0
  510.  
  511. local jumpAnimTime = 0
  512. local jumpAnimDuration = 0.3
  513.  
  514. local toolTransitionTime = 0.1
  515. local fallTransitionTime = 0.3
  516. local jumpMaxLimbVelocity = 0.75
  517.  
  518. -- functions
  519.  
  520. function stopAllAnimations()
  521. local oldAnim = currentAnim
  522.  
  523. -- return to idle if finishing an emote
  524. if (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then
  525. oldAnim = "idle"
  526. end
  527.  
  528. currentAnim = ""
  529. currentAnimInstance = nil
  530. if (currentAnimKeyframeHandler ~= nil) then
  531. currentAnimKeyframeHandler:disconnect()
  532. end
  533.  
  534. if (currentAnimTrack ~= nil) then
  535. currentAnimTrack:Stop()
  536. currentAnimTrack:Destroy()
  537. currentAnimTrack = nil
  538. end
  539. return oldAnim
  540. end
  541.  
  542. function setAnimationSpeed(speed)
  543. if speed ~= currentAnimSpeed then
  544. currentAnimSpeed = speed
  545. currentAnimTrack:AdjustSpeed(currentAnimSpeed)
  546. end
  547. end
  548.  
  549. function keyFrameReachedFunc(frameName)
  550. if (frameName == "End") then
  551.  
  552. local repeatAnim = currentAnim
  553. -- return to idle if finishing an emote
  554. if (emoteNames[repeatAnim] ~= nil and emoteNames[repeatAnim] == false) then
  555. repeatAnim = "idle"
  556. end
  557.  
  558. local animSpeed = currentAnimSpeed
  559. playAnimation(repeatAnim, 0.0, Humanoid)
  560. setAnimationSpeed(animSpeed)
  561. end
  562. end
  563.  
  564. -- Preload animations
  565. function playAnimation(animName, transitionTime, humanoid)
  566.  
  567. local roll = math.random(1, animTable[animName].totalWeight)
  568. local origRoll = roll
  569. local idx = 1
  570. while (roll > animTable[animName][idx].weight) do
  571. roll = roll - animTable[animName][idx].weight
  572. idx = idx + 1
  573. end
  574. -- print(animName .. " " .. idx .. " [" .. origRoll .. "]")
  575. local anim = animTable[animName][idx].anim
  576.  
  577. -- switch animation
  578. if (anim ~= currentAnimInstance) then
  579.  
  580. if (currentAnimTrack ~= nil) then
  581. currentAnimTrack:Stop(transitionTime)
  582. currentAnimTrack:Destroy()
  583. end
  584.  
  585. currentAnimSpeed = 1.0
  586.  
  587. -- load it to the humanoid; get AnimationTrack
  588. currentAnimTrack = humanoid:LoadAnimation(anim)
  589.  
  590. -- play the animation
  591. currentAnimTrack:Play(transitionTime)
  592. currentAnim = animName
  593. currentAnimInstance = anim
  594.  
  595. -- set up keyframe name triggers
  596. if (currentAnimKeyframeHandler ~= nil) then
  597. currentAnimKeyframeHandler:disconnect()
  598. end
  599. currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
  600.  
  601. end
  602.  
  603. end
  604.  
  605. -------------------------------------------------------------------------------------------
  606. -------------------------------------------------------------------------------------------
  607.  
  608. local toolAnimName = ""
  609. local toolAnimTrack = nil
  610. local toolAnimInstance = nil
  611. local currentToolAnimKeyframeHandler = nil
  612.  
  613. function toolKeyFrameReachedFunc(frameName)
  614. if (frameName == "End") then
  615. -- print("Keyframe : ".. frameName)
  616. playToolAnimation(toolAnimName, 0.0, Humanoid)
  617. end
  618. end
  619.  
  620.  
  621. function playToolAnimation(animName, transitionTime, humanoid)
  622.  
  623. local roll = math.random(1, animTable[animName].totalWeight)
  624. local origRoll = roll
  625. local idx = 1
  626. while (roll > animTable[animName][idx].weight) do
  627. roll = roll - animTable[animName][idx].weight
  628. idx = idx + 1
  629. end
  630. -- print(animName .. " * " .. idx .. " [" .. origRoll .. "]")
  631. local anim = animTable[animName][idx].anim
  632.  
  633. if (toolAnimInstance ~= anim) then
  634.  
  635. if (toolAnimTrack ~= nil) then
  636. toolAnimTrack:Stop()
  637. toolAnimTrack:Destroy()
  638. transitionTime = 0
  639. end
  640.  
  641. -- load it to the humanoid; get AnimationTrack
  642. toolAnimTrack = humanoid:LoadAnimation(anim)
  643.  
  644. -- play the animation
  645. toolAnimTrack:Play(transitionTime)
  646. toolAnimName = animName
  647. toolAnimInstance = anim
  648.  
  649. currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
  650. end
  651. end
  652.  
  653. function stopToolAnimations()
  654. local oldAnim = toolAnimName
  655.  
  656. if (currentToolAnimKeyframeHandler ~= nil) then
  657. currentToolAnimKeyframeHandler:disconnect()
  658. end
  659.  
  660. toolAnimName = ""
  661. toolAnimInstance = nil
  662. if (toolAnimTrack ~= nil) then
  663. toolAnimTrack:Stop()
  664. toolAnimTrack:Destroy()
  665. toolAnimTrack = nil
  666. end
  667.  
  668.  
  669. return oldAnim
  670. end
  671.  
  672. -------------------------------------------------------------------------------------------
  673. -------------------------------------------------------------------------------------------
  674.  
  675.  
  676. function onRunning(speed)
  677. if speed>0.01 then
  678. playAnimation("walk", 0.1, Humanoid)
  679. if currentAnimInstance and currentAnimInstance.AnimationId == "http://www.roblox.com/asset/?id=180426354" then
  680. setAnimationSpeed(speed / 14.5)
  681. end
  682. pose = "Running"
  683. else
  684. playAnimation("idle", 0.1, Humanoid)
  685. pose = "Standing"
  686. end
  687. end
  688.  
  689. function onDied()
  690. pose = "Dead"
  691. end
  692.  
  693. function onJumping()
  694. playAnimation("jump", 0.1, Humanoid)
  695. jumpAnimTime = jumpAnimDuration
  696. pose = "Jumping"
  697. end
  698.  
  699. function onClimbing(speed)
  700. playAnimation("climb", 0.1, Humanoid)
  701. setAnimationSpeed(speed / 12.0)
  702. pose = "Climbing"
  703. end
  704.  
  705. function onGettingUp()
  706. pose = "GettingUp"
  707. end
  708.  
  709. function onFreeFall()
  710. if (jumpAnimTime <= 0) then
  711. playAnimation("fall", fallTransitionTime, Humanoid)
  712. end
  713. pose = "FreeFall"
  714. end
  715.  
  716. function onFallingDown()
  717. pose = "FallingDown"
  718. end
  719.  
  720. function onSeated()
  721. pose = "Seated"
  722. end
  723.  
  724. function onPlatformStanding()
  725. pose = "PlatformStanding"
  726. end
  727.  
  728. function onSwimming(speed)
  729. if speed>0 then
  730. pose = "Running"
  731. else
  732. pose = "Standing"
  733. end
  734. end
  735.  
  736. function getTool()
  737. for _, kid in ipairs(Figure:GetChildren()) do
  738. if kid.className == "Tool" then return kid end
  739. end
  740. return nil
  741. end
  742.  
  743. function getToolAnim(tool)
  744. for _, c in ipairs(tool:GetChildren()) do
  745. if c.Name == "toolanim" and c.className == "StringValue" then
  746. return c
  747. end
  748. end
  749. return nil
  750. end
  751.  
  752. function animateTool()
  753.  
  754. if (toolAnim == "None") then
  755. playToolAnimation("toolnone", toolTransitionTime, Humanoid)
  756. return
  757. end
  758.  
  759. if (toolAnim == "Slash") then
  760. playToolAnimation("toolslash", 0, Humanoid)
  761. return
  762. end
  763.  
  764. if (toolAnim == "Lunge") then
  765. playToolAnimation("toollunge", 0, Humanoid)
  766. return
  767. end
  768. end
  769.  
  770. function moveSit()
  771. RightShoulder.MaxVelocity = 0.15
  772. LeftShoulder.MaxVelocity = 0.15
  773. RightShoulder:SetDesiredAngle(3.14 /2)
  774. LeftShoulder:SetDesiredAngle(-3.14 /2)
  775. RightHip:SetDesiredAngle(3.14 /2)
  776. LeftHip:SetDesiredAngle(-3.14 /2)
  777. end
  778.  
  779. local lastTick = 0
  780.  
  781. function move(time)
  782. local amplitude = 1
  783. local frequency = 1
  784. local deltaTime = time - lastTick
  785. lastTick = time
  786.  
  787. local climbFudge = 0
  788. local setAngles = false
  789.  
  790. if (jumpAnimTime > 0) then
  791. jumpAnimTime = jumpAnimTime - deltaTime
  792. end
  793.  
  794. if (pose == "FreeFall" and jumpAnimTime <= 0) then
  795. playAnimation("fall", fallTransitionTime, Humanoid)
  796. elseif (pose == "Seated") then
  797. playAnimation("sit", 0.5, Humanoid)
  798. return
  799. elseif (pose == "Running") then
  800. playAnimation("walk", 0.1, Humanoid)
  801. elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then
  802. -- print("Wha " .. pose)
  803. stopAllAnimations()
  804. amplitude = 0.1
  805. frequency = 1
  806. setAngles = true
  807. end
  808.  
  809. if (setAngles) then
  810. desiredAngle = amplitude * math.sin(time * frequency)
  811.  
  812. RightShoulder:SetDesiredAngle(desiredAngle + climbFudge)
  813. LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
  814. RightHip:SetDesiredAngle(-desiredAngle)
  815. LeftHip:SetDesiredAngle(-desiredAngle)
  816. end
  817.  
  818. -- Tool Animation handling
  819. local tool = getTool()
  820. if tool and tool:FindFirstChild("Handle") then
  821.  
  822. animStringValueObject = getToolAnim(tool)
  823.  
  824. if animStringValueObject then
  825. toolAnim = animStringValueObject.Value
  826. -- message recieved, delete StringValue
  827. animStringValueObject.Parent = nil
  828. toolAnimTime = time + .3
  829. end
  830.  
  831. if time > toolAnimTime then
  832. toolAnimTime = 0
  833. toolAnim = "None"
  834. end
  835.  
  836. animateTool()
  837. else
  838. stopToolAnimations()
  839. toolAnim = "None"
  840. toolAnimInstance = nil
  841. toolAnimTime = 0
  842. end
  843. end
  844.  
  845. -- connect events
  846. Humanoid.Died:connect(onDied)
  847. Humanoid.Running:connect(onRunning)
  848. Humanoid.Jumping:connect(onJumping)
  849. Humanoid.Climbing:connect(onClimbing)
  850. Humanoid.GettingUp:connect(onGettingUp)
  851. Humanoid.FreeFalling:connect(onFreeFall)
  852. Humanoid.FallingDown:connect(onFallingDown)
  853. Humanoid.Seated:connect(onSeated)
  854. Humanoid.PlatformStanding:connect(onPlatformStanding)
  855. Humanoid.Swimming:connect(onSwimming)
  856.  
  857. -- setup emote chat hook
  858. game.Players.LocalPlayer.Chatted:connect(function(msg)
  859. local emote = ""
  860. if (string.sub(msg, 1, 3) == "/e ") then
  861. emote = string.sub(msg, 4)
  862. elseif (string.sub(msg, 1, 7) == "/emote ") then
  863. emote = string.sub(msg, 8)
  864. end
  865.  
  866. if (pose == "Standing" and emoteNames[emote] ~= nil) then
  867. playAnimation(emote, 0.1, Humanoid)
  868. end
  869.  
  870. end)
  871.  
  872.  
  873. -- main program
  874.  
  875. local runService = game:service("RunService");
  876.  
  877. -- initialize to idle
  878. playAnimation("idle", 0.1, Humanoid)
  879. pose = "Standing"
  880.  
  881. while Figure.Parent~=nil do
  882. local _, time = wait(0.1)
  883. move(time)
  884. end
  885.  
  886.  
  887.  
  888. end,o32)
  889. end))
  890. o33.Name = "climb"
  891. o33.Parent = o32
  892. o34.Name = "ClimbAnim"
  893. o34.Parent = o33
  894. o34.AnimationId = "http://www.roblox.com/asset/?id=180436334"
  895. o35.Name = "fall"
  896. o35.Parent = o32
  897. o36.Name = "FallAnim"
  898. o36.Parent = o35
  899. o36.AnimationId = "http://www.roblox.com/asset/?id=180436148"
  900. o37.Name = "idle"
  901. o37.Parent = o32
  902. o38.Name = "Animation1"
  903. o38.Parent = o37
  904. o38.AnimationId = "http://www.roblox.com/asset/?id=180435571"
  905. o39.Name = "Weight"
  906. o39.Parent = o38
  907. o39.Value = 9
  908. o40.Name = "Animation2"
  909. o40.Parent = o37
  910. o40.AnimationId = "http://www.roblox.com/asset/?id=180435792"
  911. o41.Name = "Weight"
  912. o41.Parent = o40
  913. o41.Value = 1
  914. o42.Name = "jump"
  915. o42.Parent = o32
  916. o43.Name = "JumpAnim"
  917. o43.Parent = o42
  918. o43.AnimationId = "http://www.roblox.com/asset/?id=125750702"
  919. o44.Name = "run"
  920. o44.Parent = o32
  921. o45.Name = "RunAnim"
  922. o45.Parent = o44
  923. o45.AnimationId = "http://www.roblox.com/asset/?id=180426354"
  924. o46.Name = "sit"
  925. o46.Parent = o32
  926. o47.Name = "SitAnim"
  927. o47.Parent = o46
  928. o47.AnimationId = "http://www.roblox.com/asset/?id=178130996"
  929. o48.Name = "toolnone"
  930. o48.Parent = o32
  931. o49.Name = "ToolNoneAnim"
  932. o49.Parent = o48
  933. o49.AnimationId = "http://www.roblox.com/asset/?id=182393478"
  934. o50.Name = "walk"
  935. o50.Parent = o32
  936. o51.Name = "WalkAnim"
  937. o51.Parent = o50
  938. o51.AnimationId = "http://www.roblox.com/asset/?id=180426354"
  939. mas.Parent = workspace
  940. mas:MakeJoints()
  941. local mas1 = mas:GetChildren()
  942. for i=1,#mas1 do
  943. mas1[i].Parent = workspace
  944. ypcall(function() mas1[i]:MakeJoints() end)
  945. end
  946. mas:Destroy()
  947. for i=1,#cors do
  948. coroutine.resume(cors[i])
  949. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement