I would like to make it so a coroutine can call a function that runs in the main script (non-coroutine thread), so the coroutine can still continue its loop as before.
I ideally want these to run at the same time, however they aren’t…
This is the code
local function testFunc()
while true do
print("hi")
wait()
end
end
local function rayCast()
testFunc()
while true do
print("ray")
wait()
end
end
local testRayCoroutine = coroutine.create(rayCast)
coroutine.resume(testRayCoroutine)
This is the output
I’ve thought about using events, but I think that would just over-complicate things, especially since they are in the same script.
local function testFunc()
while true do
print("hi")
wait()
end
end
local function rayCast()
task.spawn(testFunc)
while true do
print("ray")
wait()
end
end
local testRayCoroutine = coroutine.create(rayCast)
coroutine.resume(testRayCoroutine)