How to make inverted controls?

Hello! Today I have a simple, unique, and honestly weird question, how would I make inverted controls on roblox? Like when someone presses W, it moves them backwards, and so on.

8 Likes

Your best bet would be to edit the core roblox player scripts. While I’ve not delved into them a whole lot, you’ll look for something under the category of “Control”.

Here’s a (what I hope to be) repository of mostly updated core scripts.

2 Likes

Try to set Walkspeed to a negative number I think it works

I’ve heard roblox removed that feature.

Thank you, I will check this out and see if it works!

Hello,

The way ROBLOX handles movement of a character is through a class named “ControlModule”. This class spawns a controller object for every player when they join. The controller takes input from a variety of sources such as keyboards, touchscreens and joysticks before translating it into movement.

To be able to invert controls, we want to invert that translation. Luckily for us, the aforementioned controller object has a method called “moveFunction” that it calls after dealing with all the input complexities. We’d only need to invert this moveFunction to invert controls regardless of what the input is coming from. This means our solution would work for every platform that ROBLOX supports such as PC, mobile and Xbox.

With the logic behind the solution understood, we can get to the practicals. To get access to the controller object that have spawned for a particular player, we’d firstly need a local script placed where ever it can work (remember that input from a player and physics on a character are both client-side). To grab the controller object, we need to require the PlayerModule which is automatically generated in PlayerScripts that is inside the Player instance of whomever’s controls we’re intending to invert. The hierarchy looks like so:

Capture

So far, our script would look like so:

local PLAYERS_SERVICE = game:GetService("Players")

local thisPlayer = PLAYERS_SERIVCE.LocalPlayer
local playerScripts = thisPlayer:WaitForChild("PlayerScripts")
local playerModule = require(playerScripts:WaitForChild("PlayerModule"))

After we’ve required the PlayerModule, we need to use one of its methods called GetControls. This will return the movement controller for our player. Our code will now look like this:

--// Everything same from before
local movementController = playerModule:GetControls()

Now we need to invert the moveFunction of the movement controller. By default, the moveFunction is basically the Move function of the Player instance (wiki). Used without the colons (and therefore without implicitly sending the first argument) the function accepts three parameters:

  • Player instance
  • A vector3 movement direction
  • A boolean indicating whether movement is relative to camera or not

To invert movement, we only need to invert the movement direction vector3 which is as simple as multiplying it by -1. So all that we need to do is to wrap the Move function of the Player instance inside a function which inverts this direction. Then we set this inverter function to be our new moveFunction for the movement controller. Our code would look like this:

--// Everthing same from before
movementController.moveFunction = function(player, direction, relative)
    thisPlayer.Move(player, -direction, relative)
end)

That is all. This should invert controls for every platform that ROBLOX supports. To uninvert, or to go back to normal, you’d simply set the moveFunction back to the Move function of the Player instance like so:

movementController.moveFunction = thisPlayer.Move
33 Likes

Thank you! You and @Arbeiters helped out a lot, but I have to give this one to him because he helped explain! Thanks you though!

3 Likes

Greetings, How can I make it if it goes forward it goes up and Backward for down, Etcetera?