|
If the player leaves and another script is currently iterating through a descendant of the player, will the loop error, continue, or stop after the current iteration?
|
|
devHoodieJoin Date: 2008-11-04 Post Count: 30332 |
It errors.
Done it before.
Nasty ROBLOX :(
Though if it's a Local script that doesn't effect server it wouldn't really matter now would it?
Unless the error is game breaking inside of a server script.. then no need to fix it ;p
-- Former AKA : luis15232 |
|
C_SharperJoin Date: 2011-10-03 Post Count: 9405 |
pcall? |
|
drgn42Join Date: 2010-02-11 Post Count: 3231 |
I would assume it will return an error. |
|
C_SharperJoin Date: 2011-10-03 Post Count: 9405 |
local p = game.Players.LocalPlayer
for i,v in pairs(p:GetChildren()) do
if not p then break end
end
??? |
|
devHoodieJoin Date: 2008-11-04 Post Count: 30332 |
True!
Use pcall and if it errors it'll just continue.
-- Former AKA : luis15232 |
|
|
That's kind of dumb. So I need to pcall so much. Ugh.
|
|
|
"Unless the error is game breaking inside of a server script.. then no need to fix it ;p"
Yeah but if the player leaves while the old tycoon data is being loaded or something, there's potential for errors in a number of places. Time to revert to good old pcall spam.
|
|
devHoodieJoin Date: 2008-11-04 Post Count: 30332 |
@Make
See that's game breaking c;
-- Former AKA : luis15232 |
|
|
"See that's game breaking c;"
Yeah, at least I asked here. That type of error would prevent my game from getting on the front page.
|
|
TimeTicksJoin Date: 2011-04-27 Post Count: 27115 |
Never use pcall. Ever. |
|
|
"Never use pcall. Ever."
That's silly advice.
|
|
TimeTicksJoin Date: 2011-04-27 Post Count: 27115 |
Not really. PCall hides errors you can fix. In the case of this simply,
if not p then return end
duh. |
|
|
I know what pcall does, I'm not new to scripting.
Having 20 different FindFirstChild statements is silly in a lot of cases. Sometimes pcall does the job just right.
|
|
TimeTicksJoin Date: 2011-04-27 Post Count: 27115 |
It's really bad practice. Doesn't matter what the application is. |
|
|
"It's really bad practice. Doesn't matter what the application is."
Not necessarily. Is overusing pcall bad? Sure. Can you never ever use pcall? Nah, you can, just limit its use from getting out of hand.
|
|
C_SharperJoin Date: 2011-10-03 Post Count: 9405 |
'It hides your errors so you can't fix it'
I swear it does show them. |
|
|
No pcall does hide errors.
|
|
C_SharperJoin Date: 2011-10-03 Post Count: 9405 |
Hmm. I thought I remembered a time I used a touched event with a pcall and it gave me an error. |
|
|
As long as you aren't yielding in the loop, you're fine. |
|
|
"As long as you aren't yielding in the loop, you're fine."
Alright, you sure though?
|
|
|
No it won't error and anyone who said it will didn't actually test it. The loop will finish, the only thing that has changed is the player instance is parented to nil. |
|
|
@128 how long before its destroyed? |
|
|
'As long as you aren't yielding in the loop, you're fine.'
Not true, even with a yield, it will work fine, the only thing that has changed is the player instance is parented to nil. |
|
|
@128GB
Oh, really? You're sure of this? I'll go test it in a second. That's great.
|
|