First of all, would an example of a yield be using :WaitForChild on something the doesn’t exist?
I don’t really have a clear understanding of a yield.
workspace:WaitForChild(“nonexistent”)
I was using messaging service for a game, then I started wondering, will the script yield?
local Ques = _G.Ques
local ms = game:GetService("MessagingService")
game.ServerScriptService.Binds.Subscribe.OnInvoke = function(server_name)
--will it yield? if so how can I fix it so I have have multiple requests without
--it yielding. Will I have to use coroutine?
local con = ms:SubscribeAsync(Ques[server_name]["code"],function(m)
if m == true then
Ques[server_name] = nil
end
end)
end
thanks for reading
In this case, no;
In the case of a :WaitForChild()
(without the TimeOut parameter), yes;
If you use :WaitForChild()
, it will always yield in the case that said string/object is not in the specified location after about 5 seconds, and will give you some type of infinite yield possible on ___
warning if you do not have the timeout parameter in place. An example of the timeout parameter is like this:
workspace:WaitForChild(server_name, 3) -- With 3 being the amount of seconds the WaitForChild() call with yield before continuing the code.
From what I am seeing though, I do not see any indication in your code where the code will yield, so since you are not using :WaitForChild
, your code will error instead of yield in this case provided there is a problem.
3 Likes