How can I force disable the state of mouselock

  1. What do you want to achieve?
    I’m trying to force disable the state of mouselock. So if a player is playing with mouselock enabled, I would like them to be forced out of the state of mouselock in the function. The function is already written and also disables the ability to toggle mouselock for the duration of the interaction but the problem is that if somebody has already enabled mouselock before they execute the script, they will still remain in the state of mouselock enabled despite the ability to toggle it being disabled.

Here’s the relevant section of the code:

	if player then
		if chosen then
			self.Libraries.Items.MIXING.HANDLERS[doughName](player)
		end
		
		self._mixingStation.MixingBowl["Bowl 1"].Bowl.Transparency = 1
		self._mixingStation.MixingBowl["Bowl 1"].SmoothRock.Transparency = 1
		self._mixingStation.MixingBowl["Ladle 1"].MeshPart.Transparency = 1
		
		self._isBeingUsed = false
		self._currentPlayer = nil
		self._prompt.Enabled = true
		
		wait(1)
		
		player.Character.Humanoid.WalkSpeed = 16
		player.Character.Humanoid.JumpPower = 50
		player.CameraMinZoomDistance = 0.5
		player.DevEnableMouseLock = true
	end
end

Any help is greatly appreciated, thanks!

Why do you need a script? Can’t you just disable the shiftlock by going into:

Explorer > StarterPlayerScripts > EnableMouseLockOption > false?

1 Like

Because I only want to disable mouse lock whenever the player triggers this specific function. After the function ends mouselock is enabled again.