Hello, just a quick question about pcall. Say I have this code:
pcall(function() --let's say all of these are connections EXCEPT for "u6"
u4:Disconnect();
u5:Disconnect();
u6:Disconnect();
--say an error was thrown here because "u6" was nil
u7:Disconnect(); --does the pcall stop because of the error above, or it just passes by ignoring?
u8:Disconnect();
u9:Disconnect();
u10:Disconnect();
end);
If all of the variables were connections except for “u6” which is nil, would “u7” and the other connections after it be disconnected?
It would yield until it returns an error (attempt to call method :Disconnect() on nil, in your case) or it finishes the code, and then continue the rest, thats how pcall works
pcalls are like running a seperate script. If that script returns an error, your script would get that message and continue running. If it doesn’t, your script would not get the error and continue running. Additionally, you can add a return value at the end of the function. Your script would get the returned value and the error message, both stored in tuples.