local Player = game.Players.LocalPlayer
local Character = Player.Character
local MainFrame = script.Parent
local Camera = workspace.CurrentCamera
local Humanoid = Character.Humanoid
local Mouse = Player:GetMouse()
local RunService = game:GetService("RunService")
local MaxDegree = math.rad(80)
local Connection

local currentCam = 0

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 Exceptions = {
	FP = function()
		if currentCam == 0 then
			currentCam += 1
			Camera.FieldOfView = 70
			Camera.CameraSubject = Character.Head
			updatetransparency(Player.Character)
		elseif currentCam == 1 then
			currentCam += 1
			updatetransparency(Player.Character,true)
			updatechartransparency(Player.Character)
			Camera.FieldOfView = 90
			Connection = RunService.RenderStepped:Connect(function()
				local np = Vector2.new(Mouse.X, Mouse.Y)
				local centre = Vector2.new(Camera.ViewportSize.X/2, Camera.ViewportSize.Y/2)
				local difference = np - centre

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

				Camera.CFrame = Character.Head.CFrame* CFrame.new(0,0,(-Character.Head.Size.Z/2)*1.25)* CFrame.Angles(-outcome.X, -outcome.Y,0)
			end)
		elseif currentCam == 2 then
			Connection:Disconnect()
			updatetransparency(Player.Character)
			currentCam = 0
			Camera.FieldOfView = 70
			Camera.CameraSubject = Character.Humanoid
		end

	end,
	ExcludedFrame2 = function()
	end,
	-- if the player presses a button that is not supposed to have a frame,
	-- the code in here will run.
}



local function onButtonClick(button)
	if Exceptions[button.Name] then
		Exceptions[button.Name]()
	else
		local targetFrame = MainFrame.Parent:FindFirstChild(button.Name)
		if targetFrame and targetFrame:IsA("Frame") then
			targetFrame.Visible = true
			print("Frame named '" .. targetFrame.Name .. "' is now visible.")
		else
			warn("Frame named '" .. targetFrame.Name .. "' not found.")
		end
	end
end

updatetransparency and updatechartransparency are very hard to find and i cant understand how do they work. rewrite them in an easier way to understand. don't add comments.

for _, child in MainFrame:GetChildren() do
	if child:IsA("TextButton") then
		child.MouseButton1Click:Connect(function()
			onButtonClick(child)
		end)
	end
end