As all of you may know, enabling shift-lock causes the player’s mouse to lock to the center of the screen, as well as make the character point towards the mouse’s direction. This is caused by the Player’s “PlayerModule” module-scripts, which are added by default on every experience in Roblox.
Documentation about these modules is scarce, and understanding what to look for and where can be a challenging task for any developer who was never dealt with these before.
These modules can be found by quickly running a playtest and searching in your player’s PlayerScripts Folder.
(Figure 1. Location of PlayerModule)
You must copy this modulescript to your clipboard, exit the playtest, and paste it to StarterPlayer>StarterPlayerScripts in order to make edits to it that will reflect on your final game.
(Figure 2. PlayerModule pasted to StarterPlayerScripts)
Now, to remove the shift lock rotation we must edit a module within “CameraModule”, named “CameraUtils”, as this module houses a function that overrides the behavior of the player’s rotation.
The function to look for is the following:
function CameraUtils.setRotationTypeOverride(value: Enum.RotationType)
if UserGameSettings.RotationType ~= lastRotationTypeOverride then
savedRotationType = UserGameSettings.RotationType
end
UserGameSettings.RotationType = value
lastRotationTypeOverride = value
end
As the time of writing this it can be found around line ~312, and we must only change the last two lines of code to the following:
Replace the “value” variable for Enum.RotationType.MovementRelative. And that should be it!
(Keep in mind that as a consequence of editing this function, first person will also no longer have rotation)
Now, If you also want the mouse/camera to be centered on the character, and not offset to the right, you can change the offset in a different module within CameraModule, called “MouseLockController”
Here you must modify the “CameraOffset” Vector3Value, or add one if you can’t find it.
(if you do add a vector3value object it must be named precisely "CameraOffset"
.)
EDIT:
To have finer control over when to enable shiftlock rotation, rather than permanently disabling them follow these instructions instead:
And now for some questions that I feel should be answered:
Why have I decided to make a tutorial about this topic?
As I had briefly mentioned at the start, documentation on these modules is scarce. Most of the things you can find are forum posts themselves of people looking-into and finding solutions to specific problems they have because of changes they want to make. And for entry level developers it can be an extremely daunting task to look through these modules, which include more-complicated knowledge about OOP and metatables.
But most of all, It’s mainly because I did not know how to do this myself and had to spend a handful of hours searching for answers. And the answer I did find was in reference to a PlayerScript from a previous update, in which I could not find any of the things they mentioned because the updated version of this module has really big changes . Yet it was still really insightful as it provided much needed clarity as to specifically what controls the rotating behavior.
This has lead me to decide to upload my module aswell, so future readers can compare the code to their current playermodule, and see if this tutorial is still relevant.
PlayerModule.rbxm (128.5 KB)