Custom Camera help

I’m trying to practice setting the camera to different parts and focusing the camera on other parts. The camera doesn’t seem to detach from the character and will only focus on the red part for some reason. This is the first ever time I’ve tried to set the camera, I can seem to make the camera look but not set it’s cframe and also the buttons don’t seem to work once I press red it looks at red but blue and yellow do nothing.

The buttons seem to work…

Local Script

local player = game:GetService("Players").LocalPlayer
local buttonsFrame = player.PlayerGui:WaitForChild("ScreenGui").Frame

local camera =  workspace.CurrentCamera
local cameraType = Enum.CameraType.Scriptable

local viewParts = game.Workspace.ViewParts

local CameraInfo = {
	CamButton1 = {
		location = workspace.CameraLocation.Part1,
		viewPart = workspace.ViewParts.Part1
	CamButton2 = {
		location = workspace.CameraLocation.Part2,
		viewPart = workspace.ViewParts.Part2
	CamButton3 = {
		location = workspace.CameraLocation.Part3,
		viewPart = workspace.ViewParts.Part3

for _, button in pairs(buttonsFrame:GetChildren()) do
	if button:IsA("TextButton") then
			local buttonName = button.Name

			local camInfo = CameraInfo[buttonName]
			if camInfo then
				local cameraPosition = camInfo.location.Position
				local viewPartPosition = camInfo.viewPart.Position

				camera.CFrame =, viewPartPosition)

Could be this