Troubles checking ShiftLock enabled

Hi! I am working on a little coin hunt for a few friends and I need some help. In order to reach some of the coins, the user needs to have shift lock enabled. I tried to have a Local Script in StarterPlayerScripts check if it was disabled then if it was it would show a UI. However, it won’t work for some reason. Any help?

local usettings = UserSettings():GetService("UserGameSettings")
while wait(1) do
if usettings.ControlMode == false then

game.StarterGui.ShiftLockDisabled.Frame.Visible = true

else

game.StarterGui.ShiftLockDisabled.Frame.Visible = false

end
end

I do not receive any errors either.

2 Likes

You can achieve this by checking the MouseBehavior of the player’s mouse. By checking the MouseBehavior, you should be able to tell if the mouse is locked at the center or not.
Sample code that follows your current setup:

local UserInputService = game:GetService("UserInputService")
    while wait(1) do
    if UserInputService.MouseBehavior == Enum.MouseBehavior.LockCenter then
        --do stuff
    end
end
26 Likes

eems that didn’t work. :frowning:S

Edit; It did work ( I printed to see. ) just the GUI doesn’t come up for whatever reason.

1 Like

If your mouse behavior is already set to lock center, you could use

if UserInputService.MouseIcon == "rbxasset://textures/MouseLockedCursor.png" then
	print("shift lock")
end