Parenting to workspace becomes laggy

Hello, my current issue is incredible lag whenever I attempt to parent an object to the workspace. More specifically, an object derived from ReplicatedStorage. It’s strange, because it lags the same amount for any object, doesn’t matter about part count/mesh tris. This is not so much a scripting issue but it is triggered via any command, for example:

for i = 1,5 do
	ReplicatedStorage.Assets.Pets.Bear:Clone().Parent = workspace
	print("placed object in workspace")
	wait(1)
end

There seems to be no client/server boundary, so I am thinking that it merely is the map size (~4000 parts)?

Contemporary map:

Any recommendations? Shall I remake the map?

Wheres the position of the clone? Millions could’ve spawned in at once without you knowing.

1 Like

Sorry, I don’t understand? The position is arbitatory, I’d like to add that this behavior doesn’t occur on an empty baseplate.

That’s because you are cloning 4000 parts! All on the client! If you’ve ever played the lag test 2020, you would know that 4000 parts takes time to load in(assuming you load one every frame). It took about 2 - 3 minutes, but it gets increasingly slower the more parts you have. I would recommend just parenting it to the workspace, instead of cloning it.

No, no, I’m not cloning the map, I’m only cloning one object into the workspace

Capture

I suppose my only opinion is to reduce the amount of parts within the map.

May you show us a video? Something might be running in the background(please show screenshots of the hierarchy, too)`

as you can see in the micro profiler, there are spikes everytime I equip/unequip the pet.

What is the client doing? Any scripts that are used on the client to utilize this feature?

The clients render/make the pets, but all objects that are added to the workspace make the entire server stutter.

That’s odd, mind showing the script?

I am 100% sure that it isn’t the script. I’ve isolated every script and cloned seperate objects and the same behavior occurs. I suppose I will start by stripping the map into pieces and find what mesh may be the trouble maker. Thanks for helping!

(EDIT: I had a proxy humanoid in the workspace that was probably listening into the input of the workspace. So dumb of me haha :slight_smile: )

5 Likes