Scriptable Camera Problems!

Hey guys! I recently made a scriptable camera setup that looks something like the indoors in Loomian Legacy. And I also bumped into a few problems so can anyone figure it out?
I didn’t record this video in my real game. I just copied the code and made a few parts.

Screenshots & Videos

The part on the left deactivates the scriptable camera, called ChangeCam2
The part on the right activates the scriptable camera, called ChnageCam

The video quality might be bad.

  1. I can see through a wall. I can edit my walls to make it look good, but is there anyway to stop the player from seeing through a wall?
  2. My head is a bit (actually super) shaky. The cam doesn’t shake because the CameraSubject is the HumanoidRootPart
  3. The camera doesn’t change back to what it should be.
    I haven’t found any solutions to these three on the internet yet.
local function CamCFrame(position, lookAt)
	local lookVector = (lookAt - position).Unit 
    local modelUpVector =, 1, 0)
    local rightVector = lookVector:Cross(modelUpVector)
    local upVector = rightVector:Cross(lookVector)

    return CFrame.fromMatrix(position, rightVector, upVector)

local camera = workspace.CurrentCamera
local character = game.Players.LocalPlayer.Character
	camera.CameraType = Enum.CameraType.Scriptable
repeat wait(0.01)
    camera.CFrame = CamCFrame(character.HumanoidRootPart.Position +,10,0), character.HumanoidRootPart.Position)
until camera.CameraType == Enum.CameraType.Follow
	camera.CameraType = Enum.CameraType.Follow

You’re supposed to change the camera back to Custom

U can use raycasting to make the camera not able to go trough walls

I set my game to use follow.
Or can I switch it to Custom then Follow?

This should be able to give you an idea of a solution for the walls.

I didn’t use invisicam, and my walls have a 0 transparency.