A message-error to 'WaitForChild(x)' / `FindFirstChild(x)' in script editor if statement always yields

As a Roblox developer, it is impossible to know that a WaitForChild() statement will yield in Script Editor.

Right now, error() has an “error” message saying that: “Unreachable code; previous statement always errors”, something like this for WaitForChild() and FindFirstChild() would be nice if pathway or name isn’t correct and will always yield. Having a message would seriously improve my workflow.

A message like: Yielding statement (statement always yields), consider finding the cause?

If Roblox is able to address this issue, it would improve my development experience because I wouldn’t have to run studio / play my game in order to see this error if accidentally yields for a reason.

3 Likes

Instance:FindFirstChild doesn’t yield, neither does Instance:WaitForChild if the child already exists.

error will always throw an exception – that is the point. Roblox also already warns in the console when Instance:WaitForChild yields for longer than 5 seconds and you don’t provide a timeout.

If anything this will cause a lot of faux warnings and be more annoying than helpful – Instance:WaitForChild is used extensively across games.

6 Likes