Cutscene script tween help

I’m making a script that plays a cutscene in my game and continues the cutscene when the player presses any key or button. The problem is that the tween which switches between cameras depending on the text displayed on the screen doesn’t work. The print states that the Tween is successfully completed each time.

Any help on this matter would be much appreciated.

cam.CameraType = "Scriptable"
	
while NextTut < 7 do
	wait()
	UIS.InputBegan:Connect(function(input, gameprocessed)
			if input.UserInputType == Enum.UserInputType.Keyboard or input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.MouseButton2 or input.UserInputType == Enum.UserInputType.Touch then
				if NextTut < 7 and debounce then
					debounce = false
					wait()
					print(tostring(NextTut), SpeechText.Text)
					NextTut += 1
					SpeechText.Text = SpeechTable[NextTut]
					
					if NextTut == 2 or 3 or 4 then
						local tween3 = TweenService:Create(
							cam, 
							TweenInfo.new(2, 
								Enum.EasingStyle.Sine, 
								Enum.EasingDirection.Out), 
							{
								CFrame = TutCamPositions[NextTut]
							}
						)
						tween3:Play()
						tween3.Completed:Connect(function(playbackState)
							print("tween1: "..tostring(playbackState))
						end)
						tween3.Completed:Wait()
					end
					debounce = true
					wait()
				end
			end
		end)
	end
1 Like

Are you using the Camera or the CurrentCamera object?

I’m using CurrentCamera.

(Thirtychars)

Don’t know if it’s related, but this line:

wouldn’t work. Basically you’re saying this:
If NextTut is equal to 2, or if 3 or 4 exists, then do this.

Change it to:

if NextTut == 2 or NextTut == 3 or NextTut == 4 then

end

Oh yeah. I completely missed that. Although it probably would have caused other issues, it didn’t fix the issue.

1 Like

Only potential issue I see is this here, maybe you aligned the CFrame property wrong if the Tweening is supposed to print Completed?

1 Like

I feel pretty dumb. It was because they were in the table categorised as strings, rather than numbers.

local TutCamPositions = {["2"] = TutorialCams["3"].CFrame,
		["3"] = TutorialCams["3"].CFrame,
		["4"] = TutorialCams["4"].CFrame
		}

A h

That would explain it then, but it’s fine! At least we figured out where the issue was regardless :sweat_smile:

1 Like