Coroutine not doing multiple jobs at the same time?


So, whenever I try to make multiple objects with this boolvalue inside it spin at the same time with this coroutine function, it doesn’t seem to work?

Here is the code… (serverscript) :

local cameras = workspace:WaitForChild("cameras")
local tw_se = game:GetService("TweenService")

local sttw
local wtst

for i, camera in pairs(cameras:GetChildren()) do
	if camera:IsA("Part") and camera:FindFirstChild("usable_cam") then
			sttw = tw_se:Create(camera,,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),{Orientation =, 131.091, camera.Orientation.Z)})
			wtst = tw_se:Create(camera,,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),{Orientation =, 105.61, camera.Orientation.Z)})

				while true do

I can show a video of what im talking about …:

robloxapp-20230314-1837132.wmv (997.6 KB)

Pretty much what I am trying to do here is make both of the cameras move at the same time. I don’t know why my script wont work.

I need some help on this, it would be appreciated.


whats the use of coroutine resume if you don’t mind me asking?

I explained why im using it in the thread, but will say it again. I want all of the cameras inside of my game to move at the same time. I don’t want just one to move, I want all of them to move. I added a video to show what I am talking about too, why not check it out?

If you still don’t get it, only one of the cameras (with a stringvalue the same with all of the other cams) inside of my game move. I want all of them that have the same stringvalue inside of them to move. It appears that only one is moving though and I don’t want that.

You shouldn’t need the spawn when you’re already using a coroutine, but that’s not going to be the problem. I don’t see anything wrong at first glance, would you mind adding this line under the for loop and above the if statement?

print(`{camera:GetFullName()} is{if not camera:IsA("Part") then " not" else " "} a Part and {if camera:FindFirstChild("usable_cam") then "contains" else "doesn't contain"} a child called usable_cam.`)


Can you move these two lines to the inside of the coroutine? Since these are both created at the top, I think the problem might be that everything is sharing these two variables and so each loop they are overridden with new values.

If you need to access the tweens outside of the loop, you might need to look into storing them in a table instead.

Thank you sir, I apologize for this mess.

1 Like

That’s what we’re here for. It’s a cool effect by the way, good luck with your developing!

1 Like

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