Why does this camera sequence loop not work?

Hello, heres what tells the sequence to play;

function cameraIntroHandler:camera_CheckSequence(enable)
	if enable == true then
		return true
	else
		return false
	end
end

then ill do something like this in my main script;

cameraIntroHandler:camera_CheckSequence(true)

heres the camera sequence;

local function camera_Sequence(effectedCamera)
	if not cameraIntroHandler:camera_CheckSequence() then
		print("Stop")
		return debounce
	else
		if not debounce then
			debounce = true

			--//First: Forward
			effectedCamera.CFrame = camera1.CFrame
			local tweenInformation = TweenInfo.new(3)
			local partProperties1 = {CFrame = effectedCamera.CFrame + effectedCamera.CFrame.LookVector * 5}
			local tween1 = tweenService:Create(effectedCamera, tweenInformation, partProperties1)

			tween1:Play()

			tween1.Completed:Wait(.20)

			--//Second: Left To Right
			effectedCamera.CFrame = camera2.CFrame
			local tweenInformation = TweenInfo.new(3)
			local partProperties1 = {CFrame = effectedCamera.CFrame * CFrame.Angles(0, -45, 0)}
			local tween1 = tweenService:Create(effectedCamera, tweenInformation, partProperties1)

			tween1:Play()

			tween1.Completed:Wait(.20)

			--//Third: Back
			effectedCamera.CFrame = camera3.CFrame
			local tweenInformation = TweenInfo.new(3)
			local partProperties1 = {CFrame = effectedCamera.CFrame + effectedCamera.CFrame.LookVector * -5}
			local tween1 = tweenService:Create(effectedCamera, tweenInformation, partProperties1)

			tween1:Play()

			tween1.Completed:Wait(.20)

			--//Fourth: Right To Left
			effectedCamera.CFrame = camera4.CFrame
			local tweenInformation = TweenInfo.new(3)
			local partProperties1 = {CFrame = effectedCamera.CFrame * CFrame.Angles(0, 45, 0)}
			local tween1 = tweenService:Create(effectedCamera, tweenInformation, partProperties1)

			tween1:Play()

			tween1.Completed:Wait(.20)

			debounce = false
			return debounce
		end
	end
end

It just gives me an error attempt to call a nil value why?

which line of code is erroring, that would help

cameraIntroHandler:camera_CheckSequence(true) this one

Also note im calling this in a local script the cameraIntroHandler is the module and the camera_CheckSequence(true) is the module function

I am trying to loop this

	local function camera_Sequence(effectedCamera)
		if not cameraIntroHandler:camera_CheckSequence() then
			print("Stop")
			return debounce
		else
			if not debounce then
				debounce = true

				--//First: Forward
				effectedCamera.CFrame = camera1.CFrame
				local tweenInformation = TweenInfo.new(3)
				local partProperties1 = {CFrame = effectedCamera.CFrame + effectedCamera.CFrame.LookVector * 5}
				local tween1 = tweenService:Create(effectedCamera, tweenInformation, partProperties1)

				tween1:Play()

				tween1.Completed:Wait(.20)

				--//Second: Left To Right
				effectedCamera.CFrame = camera2.CFrame
				local tweenInformation = TweenInfo.new(3)
				local partProperties1 = {CFrame = effectedCamera.CFrame * CFrame.Angles(0, -45, 0)}
				local tween1 = tweenService:Create(effectedCamera, tweenInformation, partProperties1)

				tween1:Play()

				tween1.Completed:Wait(.20)

				--//Third: Back
				effectedCamera.CFrame = camera3.CFrame
				local tweenInformation = TweenInfo.new(3)
				local partProperties1 = {CFrame = effectedCamera.CFrame + effectedCamera.CFrame.LookVector * -5}
				local tween1 = tweenService:Create(effectedCamera, tweenInformation, partProperties1)

				tween1:Play()

				tween1.Completed:Wait(.20)

				--//Fourth: Right To Left
				effectedCamera.CFrame = camera4.CFrame
				local tweenInformation = TweenInfo.new(3)
				local partProperties1 = {CFrame = effectedCamera.CFrame * CFrame.Angles(0, 45, 0)}
				local tween1 = tweenService:Create(effectedCamera, tweenInformation, partProperties1)

				tween1:Play()

				tween1.Completed:Wait(.20)

				debounce = false
				return debounce
			end
		end
	end

until the player presses play how can I do this?

After this code, you could add something like “camera_Seqeunce()”

or

you could use RunService.Heartbeat as its a function

I did do this but how can I stop it from an external script?

Maybe a remoteevent after a certain amount of times.

That seems unnecessary though I dont think I need that.

Alright nevermind I fixed it with passing a value then setting the debounce and returning it.