So I was coding a coroutine, and it doesn’t seem to work right. I am calling return at the end.
What is happening is when I call the coroutine, it is not yielding for results.
Here is some code:
The one calling it
local _, didfinish = coroutine.resume(checkcoroutine, racesize)
The actual coroutine:
local function setupcheckco()
if checkcoroutine then
coroutine.close(checkcoroutine)
local spot = table.find(zoneline[racesize], id)
if spot then
table.remove(zoneline[racesize], id)
end
end
print("got here")
checkcoroutine = coroutine.create(function (size: string): boolean
print("started")
local options = zonefolder:FindFirstChild(size):GetChildren()
if #options > 0 and #zoneline[size] == 0 then
else
print("adding")
table.insert(zoneline[size], id)
local done = Instance.new("BoolValue")
local eventcon
eventcon = FrontLineEvent.Event:Connect(function (frontid)
if frontid == id then
eventcon:Disconnect()
done.Value = true
end
end)
checkcon = eventcon
print("waiting")
done.Changed:Wait()
end
print("finishing")
unoccupied[size] -= 1
return true
end)
end