Issues with " Unable to cast CoordinateFrame to TweenInfo"

I’m getting an error with the script when interacting with my GUI button. The script tweens the camera to a part, and I’m trying to tween it back, but I get a Unable to cast CoordinateFrame to TweenInfo error every time I try to get the camera back to the player.

Script:

local TweenService = game:GetService("TweenService")
local ProximityPromptService = game:GetService("ProximityPromptService")
local Player = game.Players.LocalPlayer
local Camera = game.Workspace.CurrentCamera
local original_CF = Camera.CameraSubject.RootPart.CFrame

local set = TweenInfo.new(2, Enum.EasingStyle.Exponential, Enum.EasingDirection.InOut, 0)

repeat wait() until Player.Character 

ProximityPromptService.PromptTriggered:Connect(function(prompt)
	Camera.CameraType = "Scriptable"
	local CameraPosition = prompt.Parent.Parent.Cam.CFrame
	local target = {CFrame = CameraPosition}
	local tweenstart = TweenService:Create(Camera, set, target)
	tweenstart:Play()
	Camera.FieldOfView = 35
	local DoF1 = TweenService:Create(game.Lighting.NPCDoF, TweenInfo.new(10), {FarIntensity = 1})
	local GUI1 = TweenService:Create(game.Players.LocalPlayer.PlayerGui.Test.ImageButton, TweenInfo.new(2), {ImageTransparency = 0})
	DoF1:Play()
	GUI1:Play()

	for i,v in pairs(game.Players.LocalPlayer.Character:GetDescendants()) do 
		if v:IsA("BasePart") or v:IsA("Decal") then 
			v.Transparency = 1 
		end
	end
	game.Players.LocalPlayer.PlayerGui.Test.ImageButton.MouseButton1Click:Connect(function()
		local Camera = game.Workspace.CurrentCamera
		local target = {CFrame = game.Players.LocalPlayer.Character.Humanoid}
		local tweenstart = TweenService:Create(Camera, original_CF, target)
		tweenstart:Play()
		 
		Camera.FieldOfView = 70
	end)
end)

You’re setting the camera’s CFrame as an Instance


Also,

You’re setting the TweenInfo parameter as a CFrame

Alright, fixed that part however I’m having issues now when the camera is set to the player, I was wondering how you would recommend tweeting the camera back to the player with the camera position being the same as it was before?

(Posted my previous reply by accident)

When the prompt is triggered, save the CurrentCamera’s CFrame inside the event and tween back to the stored variable when the back button is pressed:

-- Example
ProximityPrompt.Triggered:Connect(function()
   local currentCamera = workspace.CurrentCamera
   local currentCameraCFrame = currentCamera.CFrame
   --...
   TweenService:Create(currentCamera, <TweenInfo>, {
     CFrame = currentCameraCFrame
   }):Play() -- You can tween multiple values at once
end)

P.S. you should use RBXScriptSignal:Wait or RBXScriptSignal:Once to avoid memory leaks in this case

This fixes the issue with not being able to tween out, now the issue is the camera tween when the GUI button is pressed doesn’t originate from the part that is tweens to, cam.