How do I take the player's camera to a part's position?

I want to have the player’s camera move to a part’s position for 5 seconds, then set the camera back to the player.
Here’s what I have so far:

local part = script.Parent
local camera = game.Workspace.Camera
local show = game.Workspace.Show
part.Touched:Connect(function()
	camera.postiton = show.Position
end)

You can change the camera’s CFrame after you set the CameraType to Scriptable.

repeat Camera.CameraType = Enum.CameraType.Scriptable wait() until Camera.CameraType == Enum.CameraType.Scriptable

Camera.CFrame = show.CFrame

I’m not quite sure how to reference the change of the camera. Here’s what I did.

part.Touched:Connect(function()
	Camera.CameraType("Scriptable")
	repeat Camera.CameraType = Enum.CameraType.Scriptable wait() until Camera.CameraType == Enum.CameraType.Scriptable

	Camera.CFrame = show.CFrame
end)

Remove line 2, as it does not work.

Nothing happens when the part is touched.

Can you screenshot the Output? (View > Output)

There’s nothing in the output.

Oh, is your Script a normal script, or is it a LocalScript?

Normal script, After you told me to remove line 2 there has been no errors.

Alright.

part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
	repeat Camera.CameraType = Enum.CameraType.Scriptable wait() until Camera.CameraType == Enum.CameraType.Scriptable

	Camera.CFrame = show.CFrame
end
end)

Sorry if this is confusing or anything, it just sees if the thing that hit it was actually a Player.

The camera isn’t replicated, you should be using a LocalScript. The best place for it would be StarterPlayerScripts. I may be misreading or misunderstanding, but that’s a major issue if I’m understanding correctly.

Still no results with the output or the game.

I’ll try to see if that will work.

You are correct! It was in the wrong spot.

How do I return the camera back to the player?

Camera.CameraType = Enum.CameraType.Custom should do it, if not, there are other places on the forum in which that question has been answered.

If for some reason this does not work, try:

local Camera = game.Workspace.Camera
 local original_CF = Camera.Cframe
--Code. Once done:
Camera.CameraType = Enum.CameraType.Custom
Camera.Cframe = original_CF
local userInput = game:GetService("UserInputService")

local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local camera = workspace.CurrentCamera
local part = workspace:WaitForChild("Part")

userInput.InputBegan:Connect(function(key, processed)
	if processed then
		return
	end
	
	if key.KeyCode == Enum.KeyCode.F then
		camera.CameraSubject = part
	end
end)

userInput.InputEnded:Connect(function(key, processed)
	if processed then
		return
	end
	
	if key.KeyCode == Enum.KeyCode.F then
		camera.CameraSubject = humanoid
	end
end)

Here’s a simple script which focuses the client’s camera on a BasePart instance in the workspace named “Part” whenever the “F” key is pressed (and held), once the key is released the camera’s focus returns to the player’s character.