How do I center shiftlock at character's head?

Basically regular shiflock allows you to see thru walls, I need to keep all shiftlock features but make so it cant see thru walls

I tried using camera offset whenever shiflock activates to move camera back to character head, but it doesnt support first person and very buggy

heres my cheap code prototype, I would probably keep it, but it makes character shake really bad
(btw its messy because I tried adding more stuff but it only worked worse)

local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

local plr = Players.LocalPlayer
local char = script.Parent
local hum = char:WaitForChild("Humanoid")
local root = hum.RootPart

local shiftlock = false

local UIS = game:GetService("UserInputService")

UIS:GetPropertyChangedSignal("MouseBehavior"):Connect(function()
	
	if UIS.MouseBehavior == Enum.MouseBehavior.LockCenter then
		shiftlock = true
		hum.CameraOffset = Vector3.new(-1.75, 0, 0)
		hum.AutoRotate = false
		
		RunService:BindToRenderStep("ShiftLock", Enum.RenderPriority.Character.Value, function()
			UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter 

			local _, y = workspace.CurrentCamera.CFrame.Rotation:ToEulerAnglesYXZ() 
			root.CFrame = CFrame.new(root.Position) * CFrame.Angles(0, y, 0) 
		end) 
		UserInputService.MouseIconEnabled = false
	else
		shiftlock = false
		hum.CameraOffset = Vector3.new(0, 0, 0)
		RunService:UnbindFromRenderStep("ShiftLock")
		hum.AutoRotate = true
		UserInputService.MouseIconEnabled = true
	end
end)
4 Likes

what do u mean it doesnt support first person

It just moves the camera out of the head to the right when you go first person