I’ll just paste the code and the output following it, there’s not much more context to add here (no pun intended, lol).
local function co1()
for i = 60, 0, -1 do
wait(0.5)
print("co1")
end
end
local function co2()
for i = 60, 0, -1 do
wait(1)
print("co2")
end
end
coroutine.wrap(co1())
coroutine.wrap(co2())
co1()
co2()
08:22:29.845 Baseplate auto-recovery file was created - Studio - C:/Users/boii/Documents/ROBLOX/AutoSaves
08:22:32.382 co1 - Server - Script:6
08:22:33.612 Go to Game Settings and turn on Allow HTTP requests. - Studio - Game Settings
08:22:34.617 co1 (x60) - Server - Script:6
08:23:05.650 Workspace.Part.Script:16: missing argument #1 to ‘wrap’ (function expected) - Server - Script:16
08:23:05.651 Stack Begin - Studio
08:23:05.651 Script ‘Workspace.Part.Script’, Line 16 - Studio - Script:16
08:23:05.651 Stack End - Studio
coroutine.wrap(function()
for i = 60, 0, -1 do
wait(0.5)
print("co1")
end
end)()
coroutine.wrap(function()
for i = 60, 0, -1 do
wait(0.5)
print("co2")
end
end)()
local co1 = coroutine.wrap(function()
for i = 60, 0, -1 do
wait(0.5)
print("co1")
end
end)
local co2 = coroutine.wrap(function()
for i = 60, 0, -1 do
wait(0.5)
print("co2")
end
end)
co1()
co2()
Got it, although I think they could’ve went another route with it (after you do the coroutine.wrap() the function itself becomes a thread), I still have one more question: in the code you sent to me you are not assigning a variable, how does that work?
I’d just like to add, if anyone more is reading this and was confused too, “Think of coroutine.wrap() as a function” would mean that just like a function you have to call the coroutine.wrap() and coroutine.wrap(func) would be defining the function, and then just like a function you have to assign the specific coroutine.wrap() to something to call it later i.e. a variable.
However when I did this, it didn’t work, so yeah confusion everywhere lol, although I’d like to know why it doesn’t work maybe it would be a bit too much.