I've been able to change whether or not the setting is locked, but not if it's on or off. I'm also interested in doing this at any time during the game, so setting a preset is not going to cut it (yes, I know about the StarterPlayer
setting). Here's how I lock the setting:
switch_shift_lock.OnServerEvent:Connect(function(player) player.DevEnableMouseLock = not player.DevEnableMouseLock end)
The reason it's server side is because, when I did it on the client, it said "permission denied." Or something to that effect. Anyway, I can't find a single thing to help me out. Any assistance would be greatly appreciated, Aether.
If found a way that should work to disable shift lock, but it doesn't. All it does is remove the icon for shift lock (there are no errors):
local player_scripts = player.PlayerScripts local player_module = player_scripts.PlayerModule local camera_module = player_module.CameraModule local mouse_lock_controller = require(camera_module.MouseLockController) local function disable_mouse_lock() mouse_lock_controller:EnableMouseLock(false) end -- and yes, the function is being called
Turns out, the only option for this was modifying the core scripts. Basically, I just changed a value when they entered into the area where it should be disabled and had an event listener in the core script to change whether or not the camera was locked. Credit to lu1 for this solution. While the EnableMouseLock method should've worked, it didn't (due to it being called in a different environment). Disappointed in Roblox on this one. Thank you to everyone who tried to help!
Hello,
There is a StringValue under MouseLockController
.
local player = game.Players.LocalPlayer local player_scripts = player.PlayerScripts local player_module = player_scripts.PlayerModule local camera_module = player_module.CameraModule local mouse_lock_controller = camera_module.MouseLockController local BoundKeys = mouse_lock_controller:WaitForChild("BoundKeys") --BoundKeys.Value = "" -- Disables mouse lock. --BoundKeys.Value = "LeftShift, RightShift" -- Either left or right shift will enable mouse lock! game:GetService("UserInputService").InputBegan:Connect(function(i) if i.KeyCode.Name == "X" then BoundKeys.Value = "LeftShift, RightShift" elseif i.KeyCode.Name == "Z" then BoundKeys.Value = "" end end)
Thank you, This was resolved on discord.
PS: Please accept this as an answer!