SmoothShiftLock [Module]

Hello, I’ve been making a game and wanted to add a custom smooth shift lock similar to Combat Warriors to it, so I made this module. And since I’ve seen a lot of people trying to achieve something similar I thought I would share it.

SmoothShiftLock: What does it do? It’s like default Roblox’s shift lock except it’s more smooth. When you turn your character it Lerps and not just locks into where you look, also it gives a smooth transition into the shift lock camera offset. (ShiftLock offset doesn’t actually use CameraOffset, so it looks better)

Here are the settings of the module that you can edit:

local config = {
	["CHARACTER_SMOOTH_ROTATION"]   = true,                       --// If your character should rotate smoothly or not
	["MANUALLY_TOGGLEABLE"]         = true,                       --// If the shift lock can be toggled manually by player
	["CHARACTER_ROTATION_SPEED"]    = 3,                          --// How quickly the character rotates smoothly
	["TRANSITION_SPRING_DAMPER"]    = 0.7,                        --// Camera transition spring damper, test it out to see what works for you
	["CAMERA_TRANSITION_IN_SPEED"]  = 10,                         --// How quickly locked camera moves to offset position
	["CAMERA_TRANSITION_OUT_SPEED"] = 14,                         --// How quickly locked camera moves back from offset position
	["LOCKED_CAMERA_OFFSET"]        = Vector3.new(1.75, 0.25, 0), --// Locked camera offset
	["LOCKED_MOUSE_ICON"]           =                             --// Locked mouse icon
		"rbxasset://textures/MouseLockedCursor.png",
	["SHIFT_LOCK_KEYBINDS"]         =                             --// Shift lock keybinds
		{Enum.KeyCode.LeftShift, Enum.KeyCode.RightShift}
}

A video of what it looks like in-game:


Pros:

  • Works with both R6 and R15
  • Easy to implement
  • Easy to change the settings and customize

Cons:

  • So far none

You’re free to write any feedback and let me know if you find any bugs.
Anyways, if you want to get the module it’s here:

PlayerModule Paired version:

198 Likes

This looks really cool! I quite like how the character’s rotation is also lerped! I’ll look into using this!

15 Likes

that smoothness gonna be bad for obbies but i like it! one thing that when you unshiftlock no animation plays add one!

6 Likes

also should allow head to move up and down because its just… that its too basic add head rotation too

3 Likes

I could, but this is just a custom shift lock and I don’t want to add too much stuff, also for head movement you usually have a separate script. Though I will probably make a different version with head movement in the future. :+1:

6 Likes

If you want to you can disable character smooth rotation and only keep the camera offset transition.
I also added camera offset out transition. (When you unshiftlock)

4 Likes

What would this single bug be?

4 Likes

If you enable shift lock while you are in first person and then zoom out, your cursor mouse behavior sets to default while it should be center locked.

4 Likes

I think I fixed your bug, this apparently only updates the cursor if the value is more than 1, however when zoomed in the value is 1

line 106
if distance > 0 then -- was if distance > 1 then 
	self.Camera.CFrame = (self.Camera.CFrame * self.LockOffsetProgression.Value); 
end;

other than that, i like the way its scripted, good job man!

5 Likes

It looks pretty nice, good job! Might use it for a game i’m making sometime.

4 Likes

The code you mentioned updates camera cframe with offset, distance is the distance between the player’s head and camera. I do if distance > 1 to check when the player isn’t in first person and then update the offset. (I don’t know if that’s the best way to check if the player is or not in first person)
The bug is that the cursor moves freely when it shouldn’t. I could fix it by updating the players MouseBehavior always like camera offset but that’s not the most efficient way.

3 Likes

yeah thats what i made the script do, when in first person (the distance is less than 1) which means the camera offeset will always updaets meaning the player cant move their mouse

3 Likes

This looks really nice! It reminds me of the old mouse lock feature but smoother.

4 Likes

it’s great, I decided to use it for Flee the Mall (my upcoming game)

and you use TweenService which makes the movement smooth

I think that it's a good shift-lock replacement

3 Likes

Hi, does this work with custom character models? I’m very excited to use this in my game but I want to make sure that it wouldn’t mess up any of my custom character scripts.

2 Likes

Yes, it works, just like default Roblox shiftlock would work.

2 Likes

Do you think you would be able to instead implement smooth shift lock into the player module like how most big games have it.

3 Likes

I don’t even know if that’s possible and if it is, then it’s probably very complicated and useless. Also what most big games are you talking about?

1 Like

Criminality and combat warriors have the default shift lock contained in the playermodule edited to be smooth

1 Like

Also as an addition its not useless to add it to the playermodule there is many advantages but the main one is that adding it to the playermodule would make the shift lock work with roblox’s default settings.

1 Like