How can I force shift lock when tool is equipped?

Hey, is it possible to force shift lock on a player when a certain tool is equipped? And the shift lock is disabled when the tool is unequipped?

I am currently working on a game that involves some intense 3rd person combat, and it would be great if I could enable shift lock once a player’s weapon is equipped so combat is more immersive.

If you can help, please comment down below or shoot me a DM at Raid#7008

3 Likes

There are quite a few threads on this (on the DevForum and externally)
I found this: How can I force shift lock?
This takes you specifically to the answer, but the thread may aid you too.

For example:

Tool = game:GetService("ServerStorage"):WaitForChild("foo") --// your tool here

local function toolEquipped(Mouse)
    -- force shift lock here (from the thread)

Tool.Equipped:Connect(toolEquipped)

And the same with Unequipped:

Tool = game:GetService("ServerStorage"):WaitForChild("foo") --// your tool here

local function toolUnequipped(Mouse)
    -- force shift lock here (from the thread)

Tool.Unequipped:Connect(toolEquipped)

Now, I’ve never done anything too similar to this, as I have never had to. Therefore, I’m not 100% sure if it works or if it’s just a workaround that the community has looked into. I can investigate further if necessary. :slight_smile:

8 Likes

The script doesn’t seem to have an effect, is there a way we can have a script in the tool so when a player equips it, shiftlock is enabled for them?

ForceShiftLockTool.rbxm (113.8 KB)
this is an example

Edit : first person bug fix

15 Likes

when you die it seems that the camera resets to the middle sometimes, how can I fix?

Like it removes the CameraOffset from the humanoid.

1 Like

maybe try resetting the cameraoffset through the cameramodule using a died function?

It’s not a good idea to force shift lock when a tool is equipped. I would rather you made it an option but some people don’t like using shift lock.

1 Like

3rd person shooters require shiftlock, it wouldn’t be the same without it

4 Likes

Yes but some people like me don’t like auto shift lock. Just put a settings gui in the game that says “auto shift lock”

2 Likes

I figured it out, you just have to put the script in GUI, that way when you die it resets all the scripts.

6 Likes

for me, it still bugs sometimes but in a way that I can’t move my camera with mouse

1 Like

what script do i put in the gui?

the one called ‘forceshiftlock’