I have this folder with cframe data exported from moon animator
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
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
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
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
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