How can I force a player out of shift lock?

Whenever I disable DevMouseLock, if the player is still in shift lock mode, they will stay in shift lock mode and are not able to exit it. Here is my code (server script):

local player

tool.Equipped:Connect(function()
	local player1 = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
	player = player1
	
	player.DevEnableMouseLock = true
end)

tool.Unequipped:Connect(function()
	player.DevEnableMouseLock = false
end)

Video of bug:
https://gyazo.com/dbf3821ef57c6ca70923e8b2388b06c3

4 Likes

You never told the script what “player” means. Try this:

replace

local player

with

local player = game.Players.LocalPlayer

That should fix your problem!

4 Likes

That’s not my issue, player is defined later in the code when the player equips the tool. I had to use this workaround because LocalPlayer can not be called in a server script.

My issue is that the shiftlock get’s stuck in the locked mode even when it’s set to false.

2 Likes

No, they said local player because they are going to set the variable later, as stated in the script:
player = player1

To @0929lego - have you tried printing to see if it will go through?

1 Like

The code above works as intended, however, my issue is that when I unequip the tool and I have shift lock enabled, shift lock gets stuck when I set it to false. Video example is here: https://gyazo.com/dbf3821ef57c6ca70923e8b2388b06c3

Perhaps this is what you’re looking for?

1 Like

The video you showed me doesn’t show the tool activate shift lock automatically, there’s a delay. Is it supposed to be like that?

1 Like

This is not a bug. Unfortunately it is not possible to force a player out of shift lock. DevMouseLock value only dictates if a player can toggle it, however if they are in shift lock when you disable it the camera will not update, it will stay locked to the player. The only way to force a player out of shift lock is to make a custom shift lock which would then allow you to disable it like any other script. However take it from a guy who spent weeks fighting with this. Find another way, don’t bother trying to make a custom shift lock just get around the issue some other way

3 Likes

The only way i know for disable the ShiftLock is to go on StarterPlayer and disable DevEnableMouseLock like in your script


i think the problem is, you disabled it when the shift lock is enabled so this is just blocking the user in this mod.

1 Like