This script does so that a anim plays when your walking sideways but the problem is that this happends:
Stop is not a valid member of Animation "Animation" Play is not a valid member of Animation "Animation" Why??
Heres the localscript:
local plr = game.Players.LocalPlayer local char = plr.Character local hum = char:WaitForChild("Humanoid") local UserInputService = game:GetService("UserInputService") local leftWalk = Instance.new("Animation") leftWalk.AnimationId = "rbxassetid://6046738829" local rightWalk = Instance.new("Animation") rightWalk.AnimationId = "rbxassetid://6046765944" hum:LoadAnimation(leftWalk) hum:LoadAnimation(rightWalk) UserInputService.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.D then print("Going Right") rightWalk:Play() elseif input.KeyCode == Enum.KeyCode.A then print("Going Left") leftWalk:Play() end end) UserInputService.InputEnded:Connect(function(input) if input.KeyCode == Enum.KeyCode.D then print("Animation Stop") rightWalk:Stop() elseif input.KeyCode == Enum.KeyCode.A then print("Animation Stop") leftWalk:Stop() end end)
You need to asign :LoadAnimation to a variable. For Example:
leftAnim = hum:LoadAnimation(leftWalk) rightAnim = hum:LoadAnimation(rightWalk)
After you do this leftAnim:Play() or rightAnim:Stop() will work.