How to smoothly toggle shift lock camera?

Hey! I’m just polishing my first game and I’d like to add this nice detail which isn’t overwhelming/invasive at all (since other camera features may result annoying in-combat).

I’ve found another topic asking the same question but wasn’t fully solved, there is any known feature/script/module/resource that I can use to achieve this? I’m not looking to be spoon-fed, but help would be really appreciated.

Thank you for reading!

1 Like

Hey, there is an easy solution to this.

First, you need to fork the PlayerModule script and edit the CameraModule to make it return cameraModuleObject

Now you are able to lock the mouse by doing something like this:

local CameraController = require(Player:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule")):GetCameras()

-- Locks the mouse
CameraController.activeCameraController:SetIsMouseLocked(true)

After doing that, you are able to use TweenService to tween the Humanoid’s Camera Offset which allows you to make a shift-lock over each shoulder.

A downside to this is you need to check whenever a user enters first person and then you would need to set the offset back to 0.

If there is any better way to achieve this, let me know!

2 Likes

Hey, what do you mean by “forking” the PlayerModule?

I’m actually looking for making that Tween part but, instead of setting by myself an specific camera location, just use the Roblox shift lock default one.

Thank you for replying!

Play the game in studio, open up player scripts and copy the PlayerModule then stop the game and paste it into StarterPlayerScripts which will allow you to edit it

I don’t think you can, (or it is just very clunky). Just use trial an error when you tween the Camera offset to get a position that looks good

1 Like