Is this always true?

I have developed a constant fear that if I do not use waitforchild on every single thing that it will error because it isn’t created yet.

so my question is, when I clone something, are all descendants loaded in before any other code is ran? so if I had a part in a model would it ever not be before I reference to it after cloning the model

1 Like

so like
image

is localscript always there when I’ll refer to it

1 Like

I am confused. Are you wondering if you clone a model, the cloned model will have all the original stuff the original model version had?

If there was a part in a model I cloned, and I were to change it’s color right after cloning, would it ever error because the part wasn’t loaded in yet? Or do parts/descendants always load in instantly, or atleast pause the code until it does load in.

I used to do the same thing, use wait for child’s everywhere.
But after getting more familiar with the language and how Roblox works, I tried to understand when it should be used and when it shouldn’t

In your case, a clone with scripts inside… of course the scripts parent is there, but as for children of the scripts parent or other things in the cloned object, I would probably check to make sure the script didn’t replicate and start to run first. But this might be overkill. Have you tested out to see if this ever happens?

well I’ve used clone and not waited for children in the clonse a lot but never gotten an error so maybe the children do loaded in instantly

I would feel it would be logical that before the cloned object could exist in an area where the script could run, it would have all its parts.

Probably where it might be an issue would be with replicated objects, such as sent from server to client. Or if certain things are streaming in as you get close to them, the script might fire before the objects, but I’ve never tried any of those out.

I’m just saying in general, if I were to clone a model and change a parts color in it without using waitforchild and no waits, could there be a chance that part isn’t loaded in yet, resulting in the error that it isn’t inside the model yet

I would guess that its safe., unless you find otherwise. I wouldn’t waste a waitfor on it.

2 Likes

I believe it will be stored in memory so you don’t have to use :WaitForChild on a clone

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.