Parenting small object to workspace causes CPU to hang

I am working on creating my own fishing system, and a problem I’ve been having is parenting the bobber to workspace when cast causes a short but noticeable lag-spike, inspecting the microprofiler reveals it to be the CPU hanging.

Here is the snippet of server code thats running when this spike occurs

	if inputType == "Cast" then
		local Bobber = resources.Bobber:Clone()
		Bobber.Position = script.Parent.FakeBobber.Position
		Bobber.Parent = workspace.Effects
		Bobber:SetNetworkOwner(player)
		task.defer(function()
			print("LookVector:", hrp.CFrame.LookVector)
			Bobber:ApplyImpulse(hrp.CFrame.LookVector * (1.5*castStrength))
			print("Castfromserver")
		end)
	end

I appreciate any and all help, thank you for your time!

Maybe that causes it?
It has to be syncronized between clients properly so does have some overhead i guess.

1 Like

I tried removing that line to no avail, logically that line isn’t necessary though as the player would likely claim network ownership when it spawns due to its proximity. My only guess as the why the CPU spikes is how fast the CPU would need to calculate its physics, but I have no idea why something as insignificant as this would cause it to choke.

1 Like

You sure that you are not using any beta features?
That could be engine trying to cool geometry/physics.

1 Like

I tried it in client and yeah, turns out it was studio causing the issue @_@
ty for ur help

1 Like

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