Function is not returning the camera type

This function is not returning the camera type to the player after the button is pressed.

local function returnPlayerToHumanoid(CamType)
	CC.CameraType = CamType
end

CloseCameras.MouseButton1Click:Connect(function()
	Frame.Visible = false
	returnPlayerToHumanoid(Enum.CameraType.Custom)
	print("Function finished") -- This prints successfully always.
end)



Any advice on fixing this would be great.

Are you missing CameraSubject = humanoid somewhere?

The camera subject is humanoid when I press the button.

is this a local script? if so then use workspace.CurrentCamera and set it to Enum.CameraType.Custom

Either you are running this in a server script instead of a local one or CC is no longer the current camera.

Maybe that what you want?

local function returnPlayerToHumanoid(CamType:Enum.CameraType):()
	CC.CameraType = CamType
end

CloseCameras.MouseButton1Click:Connect(function():()
	Frame.Visible = false
	returnPlayerToHumanoid(Enum.CameraType.Custom)
	print("Function finished") -- This prints successfully always.
end)