Yielding in my code seems to cause it to yield forever… not sure why.
this is a module required by a LocalScript placed in ReplicatedFirst
the code snippet shown in the image
local transition = {};
local tweenService : TweenService = game:GetService("TweenService");
local runService : RunService = game:GetService("RunService");
local client = game:GetService("Players").LocalPlayer;
local mainGui = client.PlayerGui.Container;
local spawn = function(f) return coroutine.wrap(f)() end;
local tween;
function transition:toggle()
print("begin toggle");
spawn(function()
print("in toggle new thread");
local toggled = self.toggled;
if not toggled then self.toggled = true end;
for _ , block in ipairs(self.frame:GetChildren()) do
print("Number of children of frame",#self.frame:GetChildren());
block.Visible = not block.Visible;
print("Yielding in toggle");
runService.RenderStepped:Wait();
print("done yielding");
end
if toggled then self.toggled = false end;
end)
end
local function tweenF(self)
self.frame.Position = UDim2.fromOffset(-self.size.X.Offset/2,-self.size.Y.Offset/2);
tween:Play();
print("Tween frame");
tween.Completed:Wait();
print("Tween done");
end
function transition:play()
print("Called play");
self.clearing = true;
print("Before toggle");
self:toggle();
print("After toggle");
spawn(function()
print("Before while toggled do");
while self.toggled do
tweenF(self)
end
end)
spawn(function()
while self.clearing do
print("Beginning of while clearing do");
runService.RenderStepped:Wait();
print("End of while clearing do");
end
self:toggle();
end)
end
using wait() or wait(n) yields the same problem.