(SOLVED)Toggle Shift Lock On and Off with script

I’m trying to toggle shift lock on and off with script(When I equip the gun I want to enter the shift lock state). I’ve looked into PlayerScripts and messed with MouseLockController but I couldn’t find the part where the script enables and disables it. Also I’ve seen some other threads about this topic and the responses are mostly about how you can have shiftlock from the start and keep t that way whole game(Which I don’t need). I may be looking in the wrong script.

3 Likes

Update: found the function that does it. image

4 Likes

How would I use that function?

1 Like

Please can you show which Script/LocalScript and which line this is on so other people with the same problem can use this for reference.

The function referenced in the OP is from the MouseLockController under the CameraModule of the PlayerModule. The specific code behind the function is at line 143:

OnMouseLockToggled doesn’t actually have any relevant code and is not necessarily a solution either because it only manages the mouse’s icon. If you’re interested in how the camera is moved, you’ll need to look for spots in your code relating to the function GetMouseLockOffset. The camera is offset by 1.75 studs in the X direction.