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

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.

4 Likes

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

1 Like

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.

3 Likes

When I try to rotate my camera too fast, the camera glitches a lot. Take a look:
https://gyazo.com/de4a67df77a234f54201917d3ca00970
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!

3 Likes

Does this work with Xbox or Mobile? :grinning:

1 Like

Should work just fine :slight_smile:.

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

To:

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.

1 Like

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
https://gyazo.com/fc569400810bdfa20576b278dfa7018c

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.

I presume this is used when making camera over the shoulder gun systems.

how can i disconnect the lock or shiftlock like when the intermission is the the shiftlock is disconnect or disable or i unequipped tool

1 Like
shiftLock(false)

If you have a script from the server, you can use remote events to toggle off shift lock for everyone.

2 Likes

i changed the script to this and the mouse is broken, when I disable it, it wont release the mouse

local plr = game:GetService("Players").LocalPlayer
local mouse = plr:GetMouse()
local char = script.Parent
local hum = char:WaitForChild("Humanoid")
local rotation = Instance.new("BodyGyro") 
local Root = plr.Character.HumanoidRootPart
rotation.P = 1000000 
rotation.Parent = hum.RootPart 
local conn 

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

game.ReplicatedStorage.Shiftlock.OnClientEvent:Connect(shiftLock)	
2 Likes

i fixed it myself the script is very helpfull ty

2 Likes

I’ve an odd problem, where I’ve set the character to R6, but after I implemented this script, and tested it, it’s now an R15 character. What’s going on?

1 Like