I’ve been making a game, and i’ve been trying to make a raycast function that runs a callback when the raycast hits something, here is my code:
I’ve been trying to use the coroutine library for running the callback, but i don’t exactly know the right way to do it.
It should work. All you need to do to run a coroutine is call it like a function. Here is some example code:
function MyCoolYieldingFunction(Parameters)
task.wait(9999)
print(Parameters)
end
local Arguments = 42
coroutine.wrap(MyCoolYieldingFunction)(Arguments)
If it isn’t working, try using strict typechecking to make sure you are passing in the correct types (put --!strict at the top of both the script in the picture you have shown, as well as the one that calls Tools:Raycast()).