Hello, recently for one of my games I needed to switch the left and right movements of my players, this would make walking left actually make them walk right, and walking right actually make them walk left.
This is the current code I have
local ContextActionService = game:GetService("ContextActionService")
local player = game.Players.LocalPlayer
local humanoid = player.Character:WaitForChild("Humanoid")
local HRP = player.Character:WaitForChild("HumanoidRootPart")
local function moveLeft(actionName, inputState, inputObject)
if inputState == Enum.UserInputState.Begin then
print("Rigt Began")
humanoid:Move(Vector3.new(10, 0, 0), false)
elseif inputState == Enum.UserInputState.End then
print("Right Ended")
humanoid:Move(Vector3.new(0, 0, 0), false)
end
end
local function moveRight(actionName, inputState, inputObject)
if inputState == Enum.UserInputState.Begin then
print("left Began")
humanoid:Move(Vector3.new(-10, 0, 0), false)
elseif inputState == Enum.UserInputState.End then
print("Left Ended")
humanoid:Move(Vector3.new(0, 0, 0), false)
end
end
ContextActionService:BindAction("MoveLeft", moveLeft, false, Enum.KeyCode.A)
ContextActionService:BindAction("MoveRight", moveRight, false, Enum.KeyCode.D)
The player just stands still whenever pressing left and right
Input began and Input Ended work, its only the Humanoid:Move that is not working.
Ive tried changing the values to increase the vector 3.new value.
It would be very helpful if someone could explain how to do this. Thank you