Does cloning without setting the parent cause lag?

If I were to call :Clone() several times for a large asset but never setting the parent, would this cause lag or have any effect?

1 Like

I mean it would just throw many errors at you depending on how many times you cloned it. If you cloned it so many times then the error will keep repeating itself and possibly end up causing lag but thats rare.

Why would you want to clone a part but not set the parent?

Well in my gun script, it creates the bullet.
I wasn’t sure if cloning that creates lag if they never actually shoot

Just clone it when they shoot?

Usually cloning won’t cause a big issue unless you clone something tons of time at once. If you are making a gun system, I suggest having a part limit for bullets, so bullets on the ground will be removed if new bullets is being cloned and dropped to the ground.

No. The parent of a cloned object is nil so you’re just holding on to a piece of data in memory.

1 Like

Depending on how many clones.
It won’t lag with a much ammount vut it will lag if you place 10.

What happens to that piece of data in memory? Does it buildup into untracked?

If I had to wager a guess, it would be held in PlaceMemory. It’s not exactly untracked and it can be garbage collected if you lose all references to it while it’s in nil, so it wouldn’t stick around in memory without tags and become untracked.

That being said, I don’t do much memory analysis myself or know much about how it works, so I won’t be able to provide a firm answer here. Sorry about that.