I need help on knowing how to make a player walk backwards and side to side without pressing W. It's annoying hard, and I have no clue what I'm doing wrong.

Here's the code(this is for backwards only, but if I can get help, I can do this with all "A S D") Ref of what I'm talking about: https://gyazo.com/28bd2bc6310863ebc54d22a7944050cc (side to side, and backwards walk)

Note: I'll hide my animation ID for protection of my animations

local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local Character = player.Character
local players = game:GetService("Players")

--Backward walk
UserInputService.InputBegan:connect(function(key, gameProcessedEvent)
	if not gameProcessedEvent and key.KeyCode == Enum.KeyCode.S then
  local Anim = Instance.new("Animation")
  Anim.AnimationId = "rbxassetid://AnimationID"
  local PlayAnim = Character.Humanoid:LoadAnimation(Anim)
  PlayAnim:Play()
	end
end)

UserInputService.InputEnded:connect(function(key, gameProcessedEvent)
	if not gameProcessedEvent and key.KeyCode == Enum.KeyCode.S then
  local Anim = Instance.new("Animation")
  Anim.AnimationId = "rbxassetid://AnimationID"
  local PlayAnim = Character.Humanoid:LoadAnimation(Anim)
  PlayAnim:Play()
	end
	end)

1 comment

0

Please note: I can't walk backwards when I press "w" (duh) I can only press A and D when holding W. I can let go of W when holding on to A or D.