Camera tweening script is not working

I want to make a camera tween script (like a intro or the background for the main menu, a lot of games have those, like jailbreak) but its not working here is my script:

local tween = game:GetService("TweenService")

local Cam = workspace.Camera

local CameraScenes = workspace.CameraScenes

repeat wait() until Cam.CameraSubject ~= nil

Cam.CameraType = Enum.CameraType.Scriptable
while true do
for i,v in pairs(CameraScenes:GetChildren()) do
Cam.CFrame = v["1"].CFrame
tween:Create(Cam, TweenInfo.new(1), {CFrame = v["2"].CFrame}):Play()
wait(1)
end
wait(1)
end

I was getting a script exhaustion so I added another wait(1) after the for loop. but when I run the game it only sets the camera to the first part and doesn’t do anything. (camera scenes are parts)

1 Like

The problem is this, it isn’t waiting for the tween to be completed, so it is going to run all of the tweens at the same time. Try this:

local tween = game:GetService("TweenService")

local Cam = workspace.Camera

local CameraScenes = workspace.CameraScenes

repeat wait() until Cam.CameraSubject ~= nil

Cam.CameraType = Enum.CameraType.Scriptable
while true do
for i,v in pairs(CameraScenes:GetChildren()) do
Cam.CFrame = v["1"].CFrame
local CamTween = tween:Create(Cam, TweenInfo.new(1), {CFrame = v["2"].CFrame})
CamTween:Play()
CamTween.Completed:Wait()
wait(1)
end
wait(1)
end

Ah ok, that worked. But I also found out that I didn’t have any parts in my camera scenes folder. I don’t remember deleting it. thanks for the help!

1 Like