Hello,
I’m currently trying to script inverted movement, where when a player clicks a part, it sends a remote event to the localscript, which then changes the ContextActionService Bindactions so that when W is pressed, the character moves backward, etc.
local ContextActionService = game:GetService("ContextActionService")
local RS = game:GetService('ReplicatedStorage')
local Inverted_W = 'moveBackwardAction'
local function handleAction(actionName, inputState, inputObject)
if actionName == Inverted_W and inputState == Enum.UserInputState.Begin then
print('Inverted My Friend')
end
end
local function InvertedSwitch()
ContextActionService:UnbindAction("moveBackwardAction")
ContextActionService:UnbindAction("moveForwardAction")
ContextActionService:BindAction("moveBackwardAction", handleAction,false, Enum.PlayerActions.CharacterForward )
end
RS.InvertedSwitch.OnClientEvent:Connect(InvertedSwitch)
Right now it only prints ‘Inverted My Friend’. The movement for W and S keys is disabled though, so the unbind actions worked. How do I rebind it?
I do not want to use the PlayerModule Control Script as the player may switch back and forth a lot between the different key bindnings.