How to Force Enable Shift-Lock (Without changing the PlayerModule)

Well you were right about the disconnecting any suggestion

(Also you didnt offend me lol)


You can create the connection variable outside of the function.

And instead of creating the BodyGyro every time the function runs (will work only when active is true), check if the humanoid root part has it (when active is false), because then you create a disabled BodyGyro, instead of disabling the current one.

local LockModule = {}
local conn 
function LockModule.Lock(active, plr)
	local mouse = plr:GetMouse()
	local Character = plr.Character or plr.CharacterAdded
	local hum = Character:WaitForChild("Humanoid")
	local rotation ="BodyGyro")
	rotation.P = 1000000 
	rotation.Parent = hum.RootPart
	local User = game:GetService("UserInputService")

	if active then
		hum.CameraOffset =,0.5,0) 
		rotation.MaxTorque =, math.huge, 0) 
		conn = game:GetService("RunService").RenderStepped:Connect(function()
			rotation.CFrame = mouse.Origin
			User.MouseBehavior = Enum.MouseBehavior.LockCenter
		hum.CameraOffset =,0,0) 
		rotation.MaxTorque =, 0, 0)
		if conn then conn:Disconnect() end 
		User.MouseBehavior = Enum.MouseBehavior.Default

return LockModule

Aight i finished the code now it works in a module, but would i module be better to use?

1 Like

That’s personal preference.

If you prefer to toggle shiftlock from a module, then do it from a module.
If you prefer from a function, do from the function.

My method enables shift lock in a single line from any script.

1 Like

Your method says “Modified Player Module”.

This topic is how to achieve this without modifying.

(No offense, your tutorial is great, but this topic is meant to be different :wink: )


In case anybody was wondering, the weird rotation bug mentioned earlier in the topic is due to the BodyGyro’s rotation force conflicting with the character’s auto rotation. It’s noticeable when walking backwards because the character is trying to spin around to face the movement direction.

Simple fix: set Humanoid.AutoRotate to the necessary bool value when activating or deactivating the force shift-lock.


Why not use the BindableEvent inside of the MouseLockController? just gotta parent the bindable somewhere where the client has access.

In order to not change the PlayerModule. To achieve this effect without using the PlayerModule.

The PlayerModule can change in the future, just like it did in the past. So also having a way to achieve this without editing it is also beneficial.

1 Like

When I try to rotate my camera too fast, the camera glitches a lot. Take a look:
Do you see any fix for this?

You can increase the BodyGyro’s power. It looks like you moved so fast that it didn’t even manage to fully rotate.
Try to add a few more 0’s to this:

Also, make sure the dampening is 0, if not, set it to 0 via the script.

1 Like

So your Using BodyGyro for Rotating the Body?? and also i’ve seen many People including me Back then Grabbing stuff, other People made, for my game including client sided Anti cheats (which u should never use)! And flying was always detected through BodyGyro.

So heres my Question could this be a Fly exploit Detection???

1 Like

I mean, BodyGyro is a BodyMover that is used for a whole bunch of different purposes, other than flying…

If you completely rely on BodyGyro to detect flying, then I’d advise you not to, it fits perfectly the use of BodyGyro here

All BodyGyro does is to rotate something, not move it, so a BodyGyro in the character does not nessecarily mean flying…

TL;DR, Yes, if you use such detections. I’d highly advise you not to.

An alternative could be to CFrame directly instead.

1 Like

Thanks! This Was Very Helpful Especially For An FPS Game! Was wondering how to do this and couldn’t really find anything especially not this simple!


Does this work with Xbox or Mobile? :grinning:

Should work just fine :slight_smile:.

However, if the rotation acts a bit strange, change the following line:


rotation.CFrame = workspace.CurrentCamera.CFrame

Let me know what the results are :slightly_smiling_face::crossed_fingers:

Edit (April 2022):
This now works on mobile with no need to change anything.

yeah sorry mind helping me? the rotation isn’t smooth at all and kinda like delayed? or simply it takes a bit to rotate, even with alot of 0 in the gyro.p

What is the D property of the BodyGyro set to? Is it set to 0?

it was set to 500, idk ill try to mess around with it a bit

I suggest you to set it to 0. But try to mess around with it and see what works.