Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.09 KB | None | 0 0
  1. local p = game.Players.LocalPlayer
  2. local c = game.Workspace:WaitForChild(p.Name)
  3. local ips = game:GetService("UserInputService")
  4.  
  5. local w,a,s,d,j,ch = 0,0,0,0,0,0
  6.  
  7. local canjump = true
  8. local jumped = false
  9. local cancrouch = true
  10.  
  11. local hum = c.Humanoid
  12.  
  13. local playing = false
  14.  
  15. local animfold = c:WaitForChild("anim")
  16.  
  17. ips.InputBegan:connect(function(inp)
  18.     if inp.KeyCode == Enum.KeyCode.W or inp.KeyCode == Enum.KeyCode.Up then
  19.         w = 1
  20.     end
  21.     if inp.KeyCode == Enum.KeyCode.A or inp.KeyCode == Enum.KeyCode.Left then
  22.         a = 1
  23.     end
  24.     if inp.KeyCode == Enum.KeyCode.S or inp.KeyCode == Enum.KeyCode.Down then
  25.         s = 1
  26.     end
  27.     if inp.KeyCode == Enum.KeyCode.D or inp.KeyCode == Enum.KeyCode.Right then
  28.         d = 1
  29.     end
  30.     if inp.KeyCode == Enum.KeyCode.Space or inp.KeyCode == Enum.KeyCode.ButtonA then
  31.         j = 1
  32.     end
  33.     if inp.KeyCode == Enum.KeyCode.LeftShift or inp.KeyCode == Enum.KeyCode.ButtonR2 then
  34.         ch = 1
  35.     end
  36.     print(w, a, s, d)
  37. end)
  38.  
  39. ips.InputEnded:connect(function(inp)
  40.     if inp.KeyCode == Enum.KeyCode.W or inp.KeyCode == Enum.KeyCode.Up then
  41.         w = 0
  42.     end
  43.     if inp.KeyCode == Enum.KeyCode.A or inp.KeyCode == Enum.KeyCode.Left then
  44.         a = 0
  45.     end
  46.     if inp.KeyCode == Enum.KeyCode.S or inp.KeyCode == Enum.KeyCode.Down then
  47.         s = 0
  48.     end
  49.     if inp.KeyCode == Enum.KeyCode.D or inp.KeyCode == Enum.KeyCode.Right then
  50.         d = 0
  51.     end
  52.     if inp.KeyCode == Enum.KeyCode.Space or inp.KeyCode == Enum.KeyCode.ButtonA then
  53.         j = 0
  54.     end
  55.     if inp.KeyCode == Enum.KeyCode.LeftShift or inp.KeyCode == Enum.KeyCode.ButtonR2 then
  56.         ch = 0
  57.     end
  58.     print(w, a, s, d)
  59. end)
  60.  
  61. local walk = animfold.walk
  62. local wa = hum:LoadAnimation(walk)
  63.  
  64.  
  65. game:GetService("RunService").RenderStepped:connect(function()
  66.     if w == 1 or a == 1 or s == 1 or d == 1 then
  67.         if not playing then
  68.             if walk then
  69.                 wa:Play()
  70.                 playing = true
  71.             end
  72.         end
  73.         wait()
  74.     end
  75.  
  76.     if w == 0 and a == 0 and s == 0 and d == 0 then
  77.         if playing then
  78.             wa:Stop()
  79.             playing = false
  80.         end
  81.         wait()
  82.     end
  83.    
  84.     if j == 1 then
  85.         local ja = animfold.ju
  86.         local ju = hum:LoadAnimation(ja)
  87.         ju:Play()
  88.         wait(0.3)
  89.         ju:Stop()
  90.     end
  91. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement