Camera resets to the player after each tween?

I’m making an intro sequence in my game and for some reason the camera continuously resets after every tween. I haven’t worked much with camera tweening, but I know it’s the preferred method now over interpolation. Any idea what I’m doing wrong here?

I have a model in Workspace named IntroCameraParts which contains all of the parts, and their names are simply numbers in the order of the intro sequence. It also contains parts named ‘Look#’ to give the camera a direction to look in at each part.

The code is pretty simple as well, but I may just be missing something. Here’s a gif of what I see when I run the intro sequence.

local PlayersService = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local LocalPlayer = PlayersService.LocalPlayer
local Character = ((LocalPlayer.Character and LocalPlayer.Character.Parent) and LocalPlayer.Character) or LocalPlayer.CharacterAdded:Wait()
local camParts = game.Workspace.IntroCameraParts
local cam = game.Workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Scriptable

wait(3)
for i = 1,16 do
	local Tween = TweenService:Create(cam, TweenInfo.new(1, Enum.EasingStyle.Linear), {CFrame = CFrame.new(camParts[tostring(i)].Position,camParts["Look"..tostring(i)].Position)})
	Tween:Play()
	Tween.Completed:Wait()
end
5 Likes

Hey, devTools.
I surely don’t have much experience with tweening cameras myself, but maybe you should try to set the CFrame of the camera after every tween, as I thought it may fix your problem.
Always worth a try, right?

local PlayersService = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local LocalPlayer = PlayersService.LocalPlayer
local Character = ((LocalPlayer.Character and LocalPlayer.Character.Parent) and LocalPlayer.Character) or LocalPlayer.CharacterAdded:Wait()
local camParts = game.Workspace.IntroCameraParts
local cam = game.Workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Scriptable

wait(3)
for i = 1,16 do
	local Tween = TweenService:Create(cam, TweenInfo.new(1, Enum.EasingStyle.Linear), {CFrame = CFrame.new(camParts[tostring(i)].Position,camParts["Look"..tostring(i)].Position)})
	Tween:Play()
	Tween.Completed:Wait()
    cam.CFrame = CFrame.new(camParts[tostring(i)].Position,camParts["Look"..tostring(i)].Position)
end

Let me know, if it helped :slight_smile:

3 Likes

I tried that already actually and it didn’t fix the problem. I just tried it again and it still resets the camera to the player each tween. There’s no other scripts in my game that handle the camera either, so it isn’t any issue with a separate script changing the camera or anything either. It’s a really strange issue.
Thanks for the idea though!

1 Like

Okay so the issue is that, for some reason, the camera type isn’t being set to Scriptable when I set it at the beginning. It’s possible my script runs before the player’s camera type is set to Custom by default and so my cameratype setting is overridden. I went ahead and had my code execute when a button is pressed, and set the camera type when I press the button and it works. I also just had it set the cameratype in the for loop and it works as well.

4 Likes