Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

[Solved] How can I disable ShiftLock at any time during the game?

Asked by 4 years ago
Edited 4 years ago

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
0
You'd think that Roblox would make this intuitive and easy, but nooooo... User#26971 0 — 4y
0
Did you read the question, or...? User#26971 0 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

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!

Ad
Log in to vote
0
Answered by
arshad145 392 Moderation Voter
4 years ago
Edited 4 years ago

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!

0
Only works for preventing them from turning it on, which I already know how to do. User#26971 0 — 4y

Answer this question