Cloning single part causing lag

In my game I have a gun that fires bullets.
These bullets use Raycasts and don’t rely on physics.
They are anchored, cancollide set to false and are a single part.

In my game, I started to notice every time you fired you would drop frames for half a second, enough to make it unplayable.

After a bit of testing I narrowed it down in the code to when I clone the bullet from the script and parent it to workspace. If I remove parenting it, (just cloning it), it still causes the lag.

I’ve never had this issue where cloning a single part on THE CLIENT, has caused lag.
I then tried making a basic localscript with a while loop that just inserted a part every 1/2 second and the same thing occurred.

I moved the same script over to a separate place and I had no issues. It was just at my testing place.

My testing place has barely anything in it. But when I remove almost everything from workspace, the lag when you fire disappears. The part count in my test place is about 500. None of this should be causing so much lag.

The client memory usage is also low, around 600.

Wondering if anyone has any ideas about why this is happening?

And no, I am not spamming the gun, this happens even if you fire only once.
I get constant 60 FPS when I am not firing.
And this also occurs even when I have EVERY other script in the game disabled.

Sorry for the late reply, but I do believe that using too much ray casting or using it too frequently can cause lag and FPS drops.

I’m having the same issue, that doesn’t seem to be the case because when I remove the lines where the bullet part gets cloned and parented into the workspace my game seems to be running smoothly.

Something else is going on here since a couple of these lag misconceptions are resolved with this post I recently made:

In that post, 1000 baseparts are cloned and 1000 tweens are created within the same frame and it took .013 seconds. It also showcases firing 1000 rays 1000 studs long in an empty workspace and it took .001906 seconds. The post also shows cloning 100,000 baseparts which took 1.119 seconds … not bad considering it’s 100k baseparts. So cloning and raycasting are both speedy operations. Maybe there is some kind of naming conflict or maybe the bullets aren’t baseparts?