Is there any way to yield the current thread until something happens?
For example,
game.Workspace:WaitForChild("Part")
will yield the thread until a child named 'Part' is added. Is there any other way to yield the thread?
Is there any way to yield the current thread until something happens?
For example,
game.Workspace:WaitForChild("Part")
will yield the thread until a child named 'Part' is added. Is there any other way to yield the thread?
You could do something like
while true do
newPart=Workspace.ChildAdded:Wait()
if newPart.Name=="Part" then
break
end
end
Hope this helps.
Yes, there is. You can use "repeat". For example:
repeat
--whatever code you want to repeat
until
x.Value == 30 --change this to whatever you want it to repeat until
I hope that answers your question! If so, please upvote and accept this answer.
This code will crash the game, as there is no wait() in the body of the repeat. As well, this is a laggy, busywait. Use Defaultio's method instead.
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Anyone?