I’m still learning coroutines and I was wondering if someone can help me out.
Thanks in advance!
local function task()
for cycle = 1, 150 do
PassivePb.Size = UDim2.new(0,cycle,1,0)
wait(PassiveCooldown/150)
end
end
local coro3 = coroutine.create(task)
coro3.resume() ---ERROR LINE!!!
repeat wait(.1) until coro3.Status("Dead")
--[[OUTPUT:
Players.killaman333.PlayerGui.MasterAbilityGui.MasterAbilityMain:53: attempt to index thread with 'resume'
]]
Hey!
There is an easy fix for this.
You dont do
local coro3 = coroutine.create(task)
coro3.resume()
Instead, you do
local coro3 = coroutine.create(task)
coroutine.resume(coro3)
3 Likes
Thanks for this, I stumbled on this while learning to cancel a task for the first time, and I hadn’t used coroutines much so didn’t know the syntax. In my case:
local myThread = task.delay(function() print("Sus") end)
myThread.cancel() -- Wrong
Needed to become…
local myThread = task.delay(function() print("Sus") end)
task.cancel(myThread)
Simple realization, but, just a failure on my part in reading the task library documentation.