Could you explain this a bit more and maybe provide some example code? Thanks.
I’ll provide the module here tommorow, it’s too late now. I’ll update it and ping you when I’ve done it.
Ok, for example
Heres a loop:
while true do
wait(3)
print("3 seconds have passed")
end
print("This line has been printed")
the While true do
loop is pausing the thread because its looping this function every 3 seconds non stop. As a result of this, the code after it won’t run at all.
If you place it inside a corountine function such as corountine.wrap
local thread = corountine.wrap(function()
while true do
wait(3)
print("3 seconds have passed")
end
end)
thread()
print("This line has been printed")
The loop will continue but it won’t interfere with the script itself because it’s in its own thread right now
However, in order for the thread to run, you have to call it (when using corountines)
Spawn functions operate similarly
spawn(function()
while true do
wait(5)
print("5 seconds have passed")
end
end)
For spawns, you don’t have to call them
In-case you are still slightly confused, roblox has a developer page for this
Still a bit confused, how is this relevant to the current code?
on your fix
was the reason why the script wasn’t running
What about didn’t make it run? Still confused.
while true do
is a loop so its going to loop whats inside of it. Unless break
is used inside of it, it’ll run forever and pause the script.
Try doing
corountine.wrap(function()
while wait(.5) do
Music = workspace.GlobalMusic_Folder:WaitForChild("Sound")
end
end)()
or
spawn(function()
while wait(.5) do
Music = workspace.GlobalMusic_Folder:WaitForChild("Sound")
end
end)
instead
I think I understand now! I will try this tommorow, thank you!
Just tried that out, works great! Thank you. Now I know how to do this for the future!