You can use RunService:IsStudio() to determine whether it is studio or not, and then yield. I wrote about it here.