How can I use TweenService for a camera animation?

I have this folder with cframe data exported from moon animator
image

The problem is that idk how to use tween service in a for loop to make a smooth cutscene

Here is what I got

local fps = 1/60
local folder = game:GetService("ReplicatedStorage"):WaitForChild("Camera1"):WaitForChild("Frames"):GetChildren()
local frames = #folder
local camera = workspace.CurrentCamera
---
local TS = game:GetService("TweenService")
local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0)
local Goal = Idk what to set as the goal
---

for i=1,frames do
	local cf = folder[i]
	camera.CFrame = cf.Value
	wait(fps)
end

please help

I would assume something like this:

local fps = 1/60
local frames = game:GetService("ReplicatedStorage"):WaitForChild("Camera1"):WaitForChild("Frames"):GetChildren()

table.sort(frames, function(a, b)
	return tonumber(a.Name) < tonumber(b.Name
end)

local camera = workspace.CurrentCamera

---
local TS = game:GetService("TweenService")
local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0)

for i = 1, #frames dolocal cf = frames[i]
	local Goal = {CFrame = cf.Value}
	local T = TS:Create(camera, info, Goal}
	T:Play()
	T.Finished:Wait()
	wait(fps)
end

sorry for the late reply
there were a few errors in the script so I changed it to this

local fps = 1/60
local frames = game:GetService("ReplicatedStorage"):WaitForChild("Camera1"):WaitForChild("Frames"):GetChildren()

table.sort(frames, function(a, b)
	return tonumber(a.Name) < tonumber(b.Name)
end)

local camera = workspace.CurrentCamera

---
local TS = game:GetService("TweenService")
local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0)

for i = 1, #frames do local cf = frames[i]
	local Goal = {CFrame = cf.Value}
	local T = TS:Create(camera, info, Goal)
		T:Play()
T.Completed:Wait()
wait(fps)
end

Unfortunately the script still isn’t working

What seems to be the problem with it?

The camera starts at the first frame but doesn’t move
it might have been because I change T.Finished to T.Completed

Did this because T.Finished wasn’t valid according to the output

No, that shouldn’t be the problem.

local fps = 1/60
local frames = game:GetService("ReplicatedStorage"):WaitForChild("Camera1"):WaitForChild("Frames"):GetChildren()

table.sort(frames, function(a, b)
	return tonumber(a.Name) < tonumber(b.Name)
end)

local camera = workspace.CurrentCamera

---
local TS = game:GetService("TweenService")
local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0)

for i,cf in pairs(frames) do
	local Goal = {CFrame = cf.Value}
	local T = TS:Create(camera, info, Goal)
	T:Play()
	T.Completed:Wait()
	task.wait(fps)
end

Try this instead.

I have no idea what is going on, this should be played with a local script right?

it seems to be going back and forth between the first frame and the player’s camera, but idk

That… doesn’t look right. It seems that the camera’s CFrame resets back to the original position after you change it?

Edit: change the camera type to scriptable

local fps = 1/60
local frames = game:GetService("ReplicatedStorage"):WaitForChild("Camera1"):WaitForChild("Frames"):GetChildren()

table.sort(frames, function(a, b)
	return tonumber(a.Name) < tonumber(b.Name)
end)

local camera = workspace.CurrentCamera

---
local TS = game:GetService("TweenService")
local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0)

for i,cf in pairs(frames) do
	camera.CameraType = Enum.CameraType.Scriptable
	local Goal = {CFrame = cf.Value}
	local T = TS:Create(camera, info, Goal)
	T:Play()
	T.Completed:Wait()
	task.wait(fps)
end

The same thing seems to be happening

try a repeat.

local fps = 1/60
local frames = game:GetService("ReplicatedStorage"):WaitForChild("Camera1"):WaitForChild("Frames"):GetChildren()

table.sort(frames, function(a, b)
	return tonumber(a.Name) < tonumber(b.Name)
end)

local camera = workspace.CurrentCamera

---
local TS = game:GetService("TweenService")
local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0)

repeat
	camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable

for i,cf in pairs(frames) do
	local Goal = {CFrame = cf.Value}
	local T = TS:Create(camera, info, Goal)
	T:Play()
	T.Completed:Wait()
	task.wait(fps)
end

Back again it seems to not be working still so there might be some other problem
idk what it is so we might need more help on this