Shift-lock Script

Hi!

I am trying to make an over-shoulder camera system, that also makes the player’s character face where they are looking (just like shift-lock). It kinda works but it’s really glitchy and even worse on lower-end devices. Can someone help me stop the glitching?

Script:

local SHIFT = math.rad(270)

local plr = game.Players.LocalPlayer

local camera = workspace.CurrentCamera
local run = game:GetService("RunService")
local uis = game:GetService("UserInputService")

plr.CameraMaxZoomDistance = 4
plr.CameraMinZoomDistance = 4

run.RenderStepped:Connect(function()
    local character = plr.Character or plr.CharacterAdded:Wait()
    character:WaitForChild("Humanoid").CameraOffset = Vector3.new(2, 0.25, 1.5)
    local root = character:waitForChild("HumanoidRootPart")
    local lookVec = camera.CFrame.lookVector
    local angle = -math.atan2(lookVec.Z, lookVec.X) + SHIFT
    uis.MouseBehavior = Enum.MouseBehavior.LockCenter
    root.CFrame = CFrame.new(root.Position) * CFrame.Angles(0, angle, 0)
end)

Video:

2 Likes

If you didn’t know it existed and don’t want to make it yourself:

The problem is it doesnt make the player’s character face their camera direction. If the script can actually do that then please tell me how to, but if not I’m still stuck on it. :frowning:

Think you’d want to use SetCharacterAlignment for that module to make your character rotate with the camera

image

How do I use that? I can’t seem to find it on the developer hub.

1 Like

It’s a method for the module @steven4547466 provided, so you’d need to use what he sent for your usecase

1 Like