A quick rundown is whenever the text is done displaying on the GUI i want to switch the cameras CFrame which is why I have the line wait( Text_Display_Time) to not only display the next line of text but switch the scene. Im using parts for my scenes and have them tagged However, my cameras cframe is going from index 1 - 3 and completely skipping over my 2nd cutscene part
local function animateText()
currentTextIndex = (prevTextIndex % #TEXTS) + 1
prevTextIndex = currentTextIndex
local newText = TEXTS[currentTextIndex]
local textLabelSize = TextLabel.TextBounds
local textTweenIn = TweenService:Create(TextLabel, TweenInfo.new(1), {
TextTransparency = 0,
Size = UDim2.new(0, 586, 0, 98)
})
local textTweenOut = TweenService:Create(TextLabel, TweenInfo.new(1), {
TextTransparency = 1,
Size = UDim2.new(0, 586, 0, 98)
})
textTweenOut.Completed:Connect(function()
currentText = newText
TextLabel.Text = currentText
textTweenIn:Play()
end)
textTweenIn:Play()
local currentCharacterIndex = 0
while currentCharacterIndex < #newText do
currentCharacterIndex = currentCharacterIndex + 1
TextLabel.Text = newText:sub(1, currentCharacterIndex)
wait(0.05)
end
wait(TEXT_DISPLAY_TIME)
textTweenOut:Play()
local CameraIndex = 1
for i, CameraPart in ipairs(CameraParts) do
if CameraPart == CameraPart then
CameraIndex = i
break
end
end
if CameraIndex < #CameraParts then
CameraIndex = CameraIndex + 1
else
CameraIndex = 1
end
CameraPart = CameraParts[CameraIndex]
Camera.CFrame = CameraPart.CFrame
end
local t0 = os.clock()
while os.clock() - t0 < CUTSCENE_LENGTH do
animateText()
RunService.Stepped:Wait()
end