How do i instantly end a camera loop?

  1. What do you want to achieve? Keep it simple and clear!
    I want to achieve a camera loop that breaks off instantly. I have tried many different ways and the best solution I have found so far was to create an active check to see if the button is active and to break if it wasnt.

  2. What is the issue? Include screenshots / videos if possible!
    The Camera loop isnt instantly switching to the next one camera loop it waits until the camera fully finishes the tween.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    As i previously stated I have tried to use an active check although this is good it isnt what i want. I also tried making a custom wait but I probably did it incorrectly. The last thing i did to improve the time was to add coroutines which did help significantly but still isnt exactly what i wanted.

heres a video vvv

this is the script vvv
btw reroll = customize

local function RerollCamera()
	
	--// Camera Tween
	local function TweenCameraPos(Point, Speed)
		tweenService:Create(cam, TweenInfo.new(Speed, Enum.EasingStyle.Linear), {CFrame = Point.CFrame}):Play()	
	end
	
	--// Camera Sequence
	while rerollBtn.Active do
		if rerollBtn.Active == false then return end
		cam.CFrame = campoints3:FindFirstChild("1").CFrame
		TweenCameraPos(campoints3:FindFirstChild("2"), 2)
		task.wait(2)
		if rerollBtn.Active == false then return end
		cam.CFrame = campoints3:FindFirstChild("2").CFrame
		TweenCameraPos(campoints3:FindFirstChild("3"), 2)
		task.wait(2)
		if rerollBtn.Active == false then return end
		cam.CFrame = campoints3:FindFirstChild("3").CFrame
		TweenCameraPos(campoints3:FindFirstChild("4"), 2)
		task.wait(2)
		if rerollBtn.Active == false then return end
		cam.CFrame = campoints3:FindFirstChild("4").CFrame
		TweenCameraPos(campoints3:FindFirstChild("5"), 2)
		task.wait(2)
		if rerollBtn.Active == false then return end
		cam.CFrame = campoints3:FindFirstChild("5").CFrame
		TweenCameraPos(campoints3:FindFirstChild("6"), 2)
		task.wait(2)
		if rerollBtn.Active == false then return end
		cam.CFrame = campoints3:FindFirstChild("6").CFrame
		TweenCameraPos(campoints3:FindFirstChild("1"), 2)
		task.wait(2)
		if rerollBtn.Active == false then return end
	end
end

Try this.

local function RerollCamera()

	--// Camera Tween
	local function TweenCameraPos(Point, Speed)
		task.spawn(function()
			tweenService:Create(cam, TweenInfo.new(Speed, Enum.EasingStyle.Linear), {CFrame = Point.CFrame}):Play()	
		end)
	end

	--// Camera Sequence
	while rerollBtn.Active do
		if rerollBtn.Active == false then return end
		cam.CFrame = campoints3:FindFirstChild("1").CFrame
		TweenCameraPos(campoints3:FindFirstChild("2"), 2)
		task.wait(2)
		if rerollBtn.Active == false then return end
		cam.CFrame = campoints3:FindFirstChild("2").CFrame
		TweenCameraPos(campoints3:FindFirstChild("3"), 2)
		task.wait(2)
		if rerollBtn.Active == false then return end
		cam.CFrame = campoints3:FindFirstChild("3").CFrame
		TweenCameraPos(campoints3:FindFirstChild("4"), 2)
		task.wait(2)
		if rerollBtn.Active == false then return end
		cam.CFrame = campoints3:FindFirstChild("4").CFrame
		TweenCameraPos(campoints3:FindFirstChild("5"), 2)
		task.wait(2)
		if rerollBtn.Active == false then return end
		cam.CFrame = campoints3:FindFirstChild("5").CFrame
		TweenCameraPos(campoints3:FindFirstChild("6"), 2)
		task.wait(2)
		if rerollBtn.Active == false then return end
		cam.CFrame = campoints3:FindFirstChild("6").CFrame
		TweenCameraPos(campoints3:FindFirstChild("1"), 2)
		task.wait(2)
		if rerollBtn.Active == false then return end
	end
end

its still pretty much the same

Does it work if you make the wait times lower?

ill check with lower times that may be the problem

ive checked and it has to complete the full tween before switching to the next one

i found out the code before it was slowing it down

1 Like

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