local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local gui = script.Parent
local frame = gui:WaitForChild("Frame")
local button = frame:WaitForChild("TextButton")
local camera = workspace.CurrentCamera
local part = workspace:WaitForChild("Part")
local toggle = false
button.MouseButton1Click:Connect(function()
toggle = not toggle
camera.CameraSubject = if toggle then part else humanoid
end)
This is a local script which would go inside a ScreenGui instance.