Shiftlock Issue

Hello i am in the creation of a game and i had a issue.
(I am gonna use topic creation template to be clear.)

  1. What do you want to achieve? Keep it simple and clear!
    I want to be able to enable and disable shiftlock whenever i want, with enable and disable i mean that i can force shiftlock like if someone pressed LeftShift. (not the option to toggle it)

  2. What is the issue? Include screenshots / videos if possible!
    I cant find any way to enable it, i tried enabling DevEnableMouseLock but if i disable it and then enable it again the player will not have shiftlock activated, just the option to enable it.

  3. What solutions have you tried so far? Did you look for solutions on the Creator Hub?
    DevEnableMouseLock and thats it.

Thanks for reading!

1 Like

I have modified the PlayerModule’s CameraModule so you can force-toggle the given player’s shiftlock by setting the custom SHIFTLOCK attribute under it, like so:

task.wait(2)
player:SetAttribute("SHIFTLOCK", true) -- shiftlock enabled.
task.wait(2)
player:SetAttribute("SHIFTLOCK", false) -- shiftlock disabled.

You must disable the property StarterPlayer.EnableMouseLockOption in the Studio to avoid players from they, by themselves, toggle their shiftlock, and actually forcing the attribute’s settings into, as you intend.

Attached below is the modified PlayerModule. The file is a .rbxm , meaning that you can load it directly into StarterPlayerScripts by right-clicking StarterPlayerScripts → Insert → Import Roblox Model.

PlayerModule.rbxm (139.8 KB)

Hope this helps.

1 Like

You can just use usergamesettings:rotationtype to force enable or disable shift lock their ability to enable or disable it and just do when this key is pressed usergamesetting:rotationtype = enum.rotationtype.camerarelative for shiftlock and userinputservice.mousebehavior = lockcenter

Combine thse 2 for custom shiftlock, its easier than u think
Basically

local ugs = UserSettings().GameSettings
local uis = game.UserInputService

ugs.RotationType = Enum.RotationType.CameraRelative --MovementRelative for back
uis.MouseBehavior = Enum.MouseBehaviour.LockCenter --Default for back

Sorry im in phone so spellings might be wrong

1 Like

Your method looks fine, however, it doesn’t offset the camera as in the Roblox-provided shiftlock.
Original poster asked to force shiftlock into rather than just a custom one.

The offset is 1.75,0,0 now it’s complete, isn’t it? Use cameraoffset

That’s literally what shoftlock does

Thank you for the PlayerModule, very late response but yeah, thank you, and aswell for you @YFDragonHunter67 (i dont really know how to tag a user)!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.