Hello Developers!
I was recently trying to force shiftlock upon joining the game by forking the PlayerModule but I couldn’t find a solution that fit my case. More of them were just hacky ways to force shiftlock, and the ones that used the playermodule worked, but it wasnt the “real” shiftlock I was looking for, e.g camera locked directly above player head, not supporting the mouselock cursor, etc. So I looked around in the PlayerModule a bit and found a way to do it myself.
This might not be optimal or good, it might be. I just found a solution that fit my case and wanted to share it with others.
How To Do
Somewhere around line 543 of the playermodule, you’ll find function CameraModule:OnCharacterAdded. Simply add this line of code after if self.activeOcclusionModule then and it should work:
if not self.activeMouseLockController:GetIsMouseLocked() then
self.activeMouseLockController:OnMouseLockToggled()
end
To make sure the player doesn’t disable it themselves, disable EnableMouseLockOption in the properties of StarterPlayer. This method will keep custom shiftlock cursors and uses the real roblox shiftlock.
I put it in the OnCharacterAdded spot incase something magically disables shiftlock or something other than that it should reset every time the character respawns.
The whole function should look something like this, since I know some of you are cautious when tweaking the PlayerModule:
function CameraModule:OnCharacterAdded(char, player)
if self.activeOcclusionModule then
if not self.activeMouseLockController:GetIsMouseLocked() then
self.activeMouseLockController:OnMouseLockToggled()
end
self.activeOcclusionModule:CharacterAdded(char, player)
end
end
Please tell me if I made any errors or you have any problems with this, or any ways to improve this or make it better. I unfortunately can’t include any videos but it works just like real shiftlock. This does not let you toggle it at will, there are other methods and guides for that.