Tweening script doesn't work

title, I’m trynna make a cutscene where I tween the camera to 3 parts, but it isn’t working:

local tS = game:GetService("TweenService") -- This is required or the next options like "TweenInfo.new" won't be available.

local camera = game:GetService("Workspace"):WaitForChild("Camera") -- Adding a variable for the camera.

local cutsceneTime = 12 -- Time of the cutscene.

local tI = TweenInfo.new(
	cutsceneTime,
	Enum.EasingStyle.Quint, -- How fast the camera will move.
	Enum.EasingDirection.InOut, -- The direction the camera will take.
	0, -- Depeat count
	false, -- If the cutscene reverses
	0 -- Delay time
)

local function tween(camera1, camera2, camera3) -- Adding a local function to make things more simpler, and adding a few parameters for extra simplicity.
	camera.CameraType = Enum.CameraType.Scriptable -- Making sure we can script the camera.
	camera.CFrame = camera1.CFrame -- Making sure the CFrame ( CFrame is basically the camera's position ) of the camera matches up with the part.
	
	local tween = tS:Create(camera, tI,  {CFrame = camera2.CFrame}, {CFrame = camera3.CFrame}) -- Making a variable for the tweening.
	tween:Play() -- Playing the tween.
	
	wait(cutsceneTime) -- Duration of the tween
end

wait(1) -- Adding a "wait" to make sure everything loads in.

tween(game:GetService("Workspace"):WaitForChild("CameraAngles"):WaitForChild("Island1"):WaitForChild("a"), game:GetService("Workspace"):WaitForChild("CameraAngles"):WaitForChild("Island1"):WaitForChild("b")) -- Finally tweening the parts.
tween(game:GetService("Workspace"):WaitForChild("CameraAngles"):WaitForChild("Island1"):WaitForChild("b"), game:GetService("Workspace"):WaitForChild("CameraAngles"):WaitForChild("Island1"):WaitForChild("c")) -- Since I can only tween two parts at a time, I have to write another line.

PLEASE HELP

You only passed 2 parameters in the tween function when you called it

2 Likes

I wrote on the last line of the script, where you can see im tweening b, and c.
also there is a error in output, Tried to index nil with cframe, which i beilive its refering to the {CFrame = camera3.CFrame}

You can’t put two CFrames in the tween:Create, why do you even need that line

local function tween(camera1, camera2)
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = camera1.CFrame
	
	local tween = tS:Create(camera, tI,  {CFrame = camera2.CFrame})
	tween:Play()
	
	wait(cutsceneTime)
end

wait(1)

tween(game:GetService("Workspace"):WaitForChild("CameraAngles"):WaitForChild("Island1"):WaitForChild("a"), game:GetService("Workspace"):WaitForChild("CameraAngles"):WaitForChild("Island1"):WaitForChild("b"))
tween(game:GetService("Workspace"):WaitForChild("CameraAngles"):WaitForChild("Island1"):WaitForChild("b"), game:GetService("Workspace"):WaitForChild("CameraAngles"):WaitForChild("Island1"):WaitForChild("c"))
1 Like

You’re missing the 3rd argument “camera3” when calling the function, it’s trying to get the CFrame of nil.

Ok, the tween works, but now the tween doesn’t stop; once it gets to the third part, it just stays there indefintely.

Do you want it to loop or tween twice?

1 Like

just once.
(character limit) (character limit)

In what way is it not stoping?

once it reaches the third part, it just stays there.

Is there more you want it to do because you only made it go from a to b to c

1 Like

no, thats all
( character limit)

1 Like

If you mean the third tween finishes and then the camera stays in one place, that’s because you have to set the camera back on the player manually. That’s the only way to do it, cutscenes just work like that.

1 Like

Could you help me wit that please?

Oh ok

Camera.CameraType = enum.CameraType.Custom
1 Like

No. Look it up. If you can’t find a solution online anywhere, describe your problem to ChatGPT, it’ll give you the code directly.

1 Like

ChatGPT isn’t the most accurate source for coding.

The quality of your ChatGPT answers is directly proportional to the quality of the prompts you use; in other words, if the questions you ask are bad or lazy, the answers won’t be accurate, whereas if the questions you ask are concise and relevant to solving your problem, ChatGPT will almost always come up with an elegant solution.

It is true that ChatGPT’s knowledge of roblox scripting is limited to information during and before the year 2021, but resetting your camera after a cutscene has been around since the beginning of manual camera manipulation on roblox, which is many years old.

So, anything you’re implying about ChatGPT not being accurate is simply not true, unless you ask the wrong questions. Here’s a hint: The more information you give it/the more you include in your questions, the better answers it gives.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.