Guest User

Untitled

a guest
Feb 21st, 2015
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.23 KB | None | 0 0
  1. local events = game.ReplicatedStorage
  2. local player = game.Players.LocalPlayer
  3. local char = player.CharacterAdded:wait()
  4. local torso = char:WaitForChild("Torso")
  5. local head = char:WaitForChild("Head")
  6. local hum = char:WaitForChild("Humanoid")
  7.  
  8. local animLib = require(game.ReplicatedStorage.CruxAnimation)
  9.  
  10.  
  11.  
  12. local rigs = {}
  13.  
  14.  
  15. function playAnimation(name, model, rigId)
  16.     local rig
  17.     local file = game.ReplicatedStorage.Animations:FindFirstChild(name)
  18.    
  19.     if file then
  20.         local clip = animLib.AnimationClip.new(file)
  21.         if rigs[rigId] ~= nil then
  22.             rig = rigs[rigId]
  23.             rig.Enabled = true
  24.         else   
  25.             rig = animLib.Skeleton.new(model)
  26.             rig:AddClip(clip)
  27.             rig.Enabled = true
  28.             rigs[rigId] = rig
  29.         end
  30.        
  31.         if rig:IsPlaying(name) then
  32.             rig:Stop(name)
  33.         end
  34.        
  35.         rig:Play(name)
  36.     end
  37. end
  38.  
  39.  
  40. function stopAnimation(name, model, rigId)
  41.     local rig
  42.     if rigs[rigId] ~= nil then
  43.         rig = rigs[rigId]
  44.         if rig:IsPlaying(name) then
  45.             rig:Stop(name)
  46.         end
  47.     end
  48. end
  49.  
  50.  
  51.  
  52. function humanoidRunning(speed)
  53.     if speed > 0 then
  54.         stopAnimation("Idle", char, 1)
  55.         playAnimation("Walk", char, 1)
  56.     else
  57.         stopAnimation("Walk", char, 1)
  58.         playAnimation("Idle", char, 1)
  59.     end
  60. end
  61.  
  62.  
  63.  
  64. hum.Running:connect(humanoidRunning)
Advertisement
Add Comment
Please, Sign In to add comment