Advertisement
Guest User

Untitled

a guest
Nov 11th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.99 KB | None | 0 0
  1. local Humanoid = script.Parent:WaitForChild("Humanoid")
  2. local HumanoidRootPart = script.Parent:WaitForChild("HumanoidRootPart")
  3. local w = script:WaitForChild("w")
  4. local s = script:WaitForChild("s")
  5. local a = script:WaitForChild("a")
  6. local d = script:WaitForChild("d")
  7. local playw = Humanoid:LoadAnimation(w)
  8. local plays = Humanoid:LoadAnimation(s)
  9. local playa = Humanoid:LoadAnimation(a)
  10. local playd = Humanoid:LoadAnimation(d)
  11. local uis = game:GetService("UserInputService")
  12.     local keys = {
  13.     W = false,
  14.     A = false,
  15.     S = false,
  16.     D = false
  17. }
  18. Humanoid.Running:Connect(function(speed)
  19.         if speed > .5 then
  20.             if keys.W == true then
  21.            playw:Play()
  22.         if plays.IsPlaying == true or playa.IsPlaying == true or playd.IsPlaying == true then
  23.             plays:Stop()
  24.             playa:Stop()
  25.             playd:Stop()
  26.                 else
  27.             end
  28.         end
  29.      if keys.S == true then
  30.            plays:Play()
  31.         if playw.IsPlaying == true or playa.IsPlaying == true or playd.IsPlaying == true then
  32.             playw:Stop()
  33.             playa:Stop()
  34.             playd:Stop()
  35.                 else
  36.             end
  37.         end
  38.      if keys.A == true then
  39.            playa:Play()
  40.         if plays.IsPlaying == true or playw.IsPlaying == true or playd.IsPlaying == true then
  41.             plays:Stop()
  42.             playw:Stop()
  43.             playd:Stop()
  44.                 else
  45.             end
  46.         end
  47.      if keys.D == true then
  48.            playd:Play()
  49.         if plays.IsPlaying == true or playa.IsPlaying == true or playw.IsPlaying == true then
  50.             plays:Stop()
  51.             playa:Stop()
  52.             playd:Stop()
  53.                 else
  54.             end
  55.         end
  56.     end
  57. end)
  58. uis.InputBegan:Connect(function(input, processed)
  59.     if keys.W and not processed then
  60.         keys.W = true
  61.     elseif keys.S and not processed then
  62.         keys.S = true
  63.     elseif keys.A and not processed then
  64.         keys.A = true
  65.     elseif keys.D and not processed then
  66.         keys.D = true
  67.     end
  68. end)
  69. uis.InputEnded:Connect(function(input, bool)
  70.     if keys.W then
  71.         keys.W = false
  72. elseif keys.A then --do the other keys
  73.     keys.A = false
  74. elseif keys.S then
  75.     keys.S = false
  76. elseif keys.D then
  77.     keys.D = false
  78.     end
  79. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement