wait(1);
cam = workspace.CurrentCamera;
pal = game.Players.LocalPlayer.Character;
local Player = game.Players.LocalPlayer
local mouse = Player:GetMouse()
local run = game:GetService("RunService")
local maxDegree = math.rad(80)

deb = "TPS";

function updatetransparency(targ,bool)
	for i,v in pairs(targ:GetChildren()) do
		if v:IsA("Accessory") then
			updatetransparency(v,bool)
		elseif v:IsA("BasePart") then
			--HatAttachment FaceCenterAttachment HairAttachment NeckAttachment
			if v:FindFirstChild("HatAttachment") or v:FindFirstChild("FaceCenterAttachment")
				or v:FindFirstChild("FaceFrontAttachment")
				or v:FindFirstChild("FaceRearAttachment")
				or v:FindFirstChild("HairAttachment") or v:FindFirstChild("NeckAttachment") then
				if bool then
					v.LocalTransparencyModifier = 1					
				else
					v.LocalTransparencyModifier = v.Transparency
				end
			end
		end
	end
end

function updatechartransparency(targ,bool)
	for i,v in pairs(targ:GetChildren()) do
		if v:IsA("BasePart") then
			if bool or v.Name == "Head" then
				v.LocalTransparencyModifier = 1					
			else
				v.LocalTransparencyModifier = v.Transparency
			end
			updatetransparency(v,bool)
		elseif v:IsA("Folder") or v:IsA("Model") then
			updatetransparency(v,bool)
		end
	end
end

local renderrrrrr = game:GetService("RunService").RenderStepped;
script.Parent.MouseButton1Click:connect(function()
	if deb == "FPS" then
		if Player.Character then
			cam.CameraType = "Custom";
			deb = "TPS"
			local char = Player.Character
			if char:FindFirstChild("Humanoid") then
				cam.CameraSubject = char.Humanoid
				script.Parent.Parent.PreviewFP.Text = "IN THIRD PERSON VIEW"
				cam.FieldOfView = 70
			end
			updatetransparency(Player.Character)
		end
	elseif deb == "TPS" then
		if Player.Character then
			cam.CameraType = "Custom";
			deb = "TPSHead"
			local char = Player.Character
			if char:FindFirstChild("Head") then
				cam.CameraSubject = char.Head
				script.Parent.Parent.PreviewFP.Text = "IN THIRD PERSON VIEW (HEAD FOCUS)"
				cam.FieldOfView = 70
			end
			updatetransparency(Player.Character)
		end
	elseif deb == "TPSHead" then
		cam.CameraType = "Scriptable";
		deb = "FPS"
		script.Parent.Parent.PreviewFP.Text = "IN FIRST PERSON VIEW"
		
		if Player.Character then
			updatetransparency(Player.Character,true)
			updatechartransparency(Player.Character)
			cam.FieldOfView = 90
		end
		while true do
			if Player.Character then
				local char = Player.Character

				if char:FindFirstChild("Head") then
					local np = Vector2.new(mouse.X, mouse.Y)
					local centre = Vector2.new(cam.ViewportSize.X/2, cam.ViewportSize.Y/2)
					local difference = np - centre

					local outcome = Vector2.new((difference.Y/centre.Y)*maxDegree, (difference.X/centre.X)*maxDegree)

					cam.CFrame = char.Head.CFrame
						* CFrame.new(0,0,(-char.Head.Size.Z/2)*1.25)
						* CFrame.Angles(-outcome.X, -outcome.Y,0)
				end
			end
			renderrrrrr:wait();
			if deb ~= "FPS" or not Player.Character then
				break;
			end;		
		end;
	end
	
	--[[
	local np = Vector2.new(mouse.X, mouse.Y)
	local centre = Vector2.new(cam.ViewportSize.X/2, cam.ViewportSize.Y/2)
	local difference = np - centre

	local outcome = Vector2.new((difference.Y/centre.Y)*maxDegree, (difference.X/centre.X)*maxDegree)

	cam.CFrame = campartttt.CFrame * CFrame.Angles(-outcome.X, -outcome.Y,0)
	]]
end);

optimize this and make this readable. don't add comments and don't add explanations.