Help with custom shift lock

I’m trying to make custom shift lock and it’s sort of working but I just need to reset the camera after the player hits shift again so that their camera is normal, how would I do that? The character also isn’t facing the camera so I need help fixing that as well
If there’s a better way to do this, please let me know

local CAS = game:GetService('ContextActionService')
local UIS = game:GetService('UserInputService')
local camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild('Humanoid')
local RS = game:GetService('RunService')

local shiftlock = false

local runservice 

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift and shiftlock == false then
		shiftlock = not shiftlock
		UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
		humanoid.CameraOffset = humanoid.CameraOffset + Vector3.new(3,0,0)
		runservice = RS.RenderStepped:Connect(function()
			character.PrimaryPart.CFrame = CFrame.new(character.PrimaryPart.CFrame.p + Vector3.new(camera.CFrame.LookVector.X,0,camera.CFrame.LookVector.Z))
		end)
	elseif input.KeyCode == Enum.KeyCode.LeftShift and shiftlock == true then
		shiftlock = not shiftlock
		UIS.MouseBehavior = Enum.MouseBehavior.Default
		runservice:Disconnect()
		--HOW DO YOU RESET THE CAMERA
		
	end
end)
1 Like

To reset the camera

Camera.CameraType = Enum.CameraType.Custom

To script the camera

Camera.CameraType = Enum.CameraType.Scriptable

There’s many ways to align the character’s root part with the camera, you either rotate the RootPart Y angles to match the camera’s or you make the RootPart CFrame match the camera cframe ignoring the Y axis

use chat GPT for this if you want to learn faster, and make an effort to memorize it.

1 Like

Where in the script would I change the camera types? It still isn’t working

place humanoid.CameraOffset = Vector3.zero in the elseif