Hello, I have been trying to fix this for quite a bit now (roughly 4 hours), and it’s been a real pain. What I am trying to do is make the current camera loop through cameras in the game, they are in folders in workspace called sector. The main issue with this is I cannot seem to stop the tween, I’ve tried Tween:Cancel(), Tween:Stop() and I also tried breaking the loop, but it does not work. It might be because of Tween.Completed:wait(), but I’m not entirely sure. Help would be greatly appreciated as this is essential for the game I am making.
When I press “Play”, the tween does not stop and it waits until it’s completed, but as I said before I want to stop the tween before it gets to the other camera.
GIF of the issue
The GIF above shows the Tween keep playing after I break / stop the tween.
Module code:
Code
function setup.stop()
stopped = true
camera.CameraType = Enum.CameraType.Custom
camera.CameraSubject = char
end
function setup.start()
local current_tab = 1
local current_sector = tab[1]
local default_sector = tab[1]
local current = 1
local default_camera = menu_cameras[default_sector]:FindFirstChild(“1”)
local tween_speed = 20
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = default_camera.CFrame
local newTween
while true do
if stopped then
newTween:Stop()
break
end
for _,v in next, menu_cameras[tab[current_tab]]:GetChildren() do
local numCameras = #menu_cameras[tab[current_tab]]:GetChildren()
current = current + 1
if current > numCameras then
current = 2
if #tab > 1 then
current_tab = current_tab + 1
if current_tab > #tab then
current_tab = 1
end
end
camera.CFrame = menu_cameras[tab[current_tab]][default_camera.Name].CFrame
end
newTween = libModule.tween(camera, TweenInfo.new(tween_speed, Enum.EasingStyle.Linear), {CFrame = menu_cameras[tab[current_tab]][current].CFrame})
newTween:Play()
newTween.Completed:wait()
end
end
end
I call module.stop() in a LocalScript.
Like I said before, help would be greatly appreciated.