Camera system doesn't stop tween after status is changed

Hello, I have a bit of code that when the variable camerastate is changed, it doesn’t change to the next function. What it is supposed to do is break the repeat until loop and move on to the next set of cameras.

local function idle()
		repeat
			local idlecameras = cameras.Idle_Cams
			local camerasequence = {idlecameras.Cam1, idlecameras.Cam2, idlecameras.Cam3, idlecameras.Cam4, idlecameras.Cam5, idlecameras.Cam6, idlecameras.Cam7}
			for i = 1, #camerasequence - 1 do
				local ran = math.random(i, #camerasequence)
				camerasequence[i], camerasequence[ran] = camerasequence[ran], camerasequence[i]
			end
			for i, v in pairs(camerasequence) do
				if camerastate.Value == "Idle" and tv_mode_enabled.Value then
					if v.Name == "Cam1" then
						camera.CFrame = v.CFrame
						wait(0.7)
						local ti = TweenInfo.new(8, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
						local Goal = {CFrame = idlecameras.Cam1End.CFrame}
						current_tween = TweenService:Create(camera, ti, Goal)
						current_tween:Play()
						wait(9)
					elseif v.Name == "Cam2" then
						camera.CFrame = v.CFrame
						wait(4.5)
					elseif v.Name == "Cam3" then
						camera.CFrame = v.CFrame
						wait(0.7)
						local ti = TweenInfo.new(8, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
						local Goal = {CFrame = idlecameras.Cam3End.CFrame}
						current_tween = TweenService:Create(camera, ti, Goal)
						current_tween:Play()
						wait(9)	
					elseif v.Name == "Cam4" then
						camera.CFrame = v.CFrame
						wait(0.7)
						local ti = TweenInfo.new(8, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
						local Goal = {CFrame = idlecameras.Cam4End.CFrame}
						current_tween = TweenService:Create(camera, ti, Goal)
						current_tween:Play()
						wait(9)
					elseif v.Name == "Cam5" then
						camera.CFrame = v.CFrame
						wait(0.7)
						local ti = TweenInfo.new(8, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
						local Goal = {CFrame = idlecameras.Cam5End.CFrame}
						current_tween = TweenService:Create(camera, ti, Goal)
						current_tween:Play()
						wait(9)
					elseif v.Name == "Cam6" then
						camera.CFrame = v.CFrame
						wait(4.5)
					elseif v.Name == "Cam7" then
						camera.CFrame = v.CFrame
						wait(4.5)
					end
				else
					break
				end	
			end
		until not tv_mode_enabled.Value or camerastate.Value ~= "Idle"
	end

My goal is to implement current_tween:Pause() so that it skips the wait and moves on to the next.

I am still confused on this, can anyone help me out?

1 Like

I think you just need to fill out your TweenInfo
TweenInfo (roblox.com)
the final 3 argument is how many times to repeat, whether to reverse, and delay.

1 Like

But my tweens don’t repeat at all, they go in a sequence. What I am looking to do is immediately stop the tween when the camerastate value is changed.

1 Like

You would need to call

current_tween:Stop

I think it’s etheir TweenBase:Cancel() or TweenBase:Pause(), problem. is loop still iterates

Two things:
it’s: current_tween:Cancel()

second from reading your code, your loop will run once then will stop iterating once tv_mode_enabled.Value == false or camerastate.Value == <something other then idle>

Now once those conditions are met you would do this after until not tv_mode_enabled.Value or camerastate.Value ~= "Idle
and before end you would call current_tween:Cancel()

Hopefully that helps