What does "Instance.fromExisiting" do?

Hello!

I recently saw that Instance had a new constructor and I’m not really sure what it does. The documentation said it worked very similar to Instance:Clone(), so do I need to use it? What exactly is the purpose of this? In what cases would I use this?

Thank you for your answers and have a wonderful day! :slight_smile:

4 Likes

its basically like clone but it doesnt copy the children and copies the instance even when archivable is set to false

1 Like

I read that it did that, but what the purpose for it? Is it supposed to be better than :Clone() at times?

1 Like

@tnavarts could likely shed some better light on its exact purpose, but from what I understand, it’s for convenience when you need to clone an Instance without its children (which could lead to some performance gains)

4 Likes

Thanks for the answer! I wasn’t sure if it was better for performance or not, but now I know! If I have any further questions, I’ll ask @tnavarts. Have a wonderful day! :slight_smile:

From the doc: Instance | Documentation - Roblox Creator Hub

Creates a new object with the same type and property values as an existing object. In most cases using Instance:Clone() is more appropriate, but this constructor is useful when implementing low‑level libraries or systems.

For example, if you were implementing a custom streaming solution for your experience you might want to partially clone objects using fromExisting.

You probably want good ol’ Clone almost all the time, fromExisting is intended for use by authors of low level library code who need more control over how stuff is cloned.

1 Like

Thanks for your response! I think I get it now!

What does that mean?

Like, general systems rather than specific game logic. If I go to the trouble of writing a custom streaming system I’m probably going to re-used it across several different games, with the code in that streaming system not knowing any details about the individual games.

1 Like

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