Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does coroutine.wrap not allow me to use camera.CFrame, while spawn() does?

Asked by 4 years ago

I had a function that when called would use TweenService to move the camera, but it cant start at the players location, so I moved it. The problem was that it would not let me use camera.CFrame when wrapping the function in coroutine unless it was done by Tween:Play(). The problem is solved when using spawn() instead, but I have no idea why it is doing this. Although this doesnt break the code, the included wait in spawn is a bit annoying, but the code still functions. If anybody could explain that would be great.

0
That is more false than ever. Coroutines don't pause for an existing thread. It just creates a new thread to run code in (somewhat) parallel. Anywho, remember that coroutines need to be called. For example, coroutine.wrap(function() ... end)(); or coroutine.resume(coroutine.create(...)). For clarity, JesseSongs deleted his post. Sorry.  Fifkee 2017 — 4y

Answer this question