I don’t got a lot to say / type but does pcall not protect against all errors that could happen within the function?
I tried to wait for a child in a pcall so that if it inf yield the rest of my code doesn’t get affected but it seems to globally affect everything for some reason.
Example of how code was:
local Parent = path.to.parent
local Child = nil
local Succ, Err = pcall(function(...)
Child = Parent:WaitForChild("NonexistentChild")
A pcall doesn’t run on a new thread. That wait will affect everything after it.
Pcall are supposed to protect against all errors (what i believe) it doesn’t need to be a new thread
All it does is run the code, and return a status based on whether or not an error occurred. It doesn’t ignore waits. It will exit if an error occurs, but an infinite yield isn’t an error, because you could just be waiting for the part to load later.
If you want it to ignore the wait, run it on a new thread.
try putting the pcall into another pcall
WaitForChild doesn’t error. So yes the pcall will wait forever and not ever claim there was an error that was skipped.
pcall to protect against all errors alone. The
pcall is meant to be a logical structure to divert code from complete halt to handling the error. The thread continues without any failure after that.
use task.spawn as infinite yields arent errors
wow never thought of that
My goal was to catch this tho…
It was like a GetChild method that would return the child by first using FindFirstChild then looping through children then the final wait for child