An overload of parts causes game to lag. Is there a solution?

Title. I have a part spawner that spawns a random colored brick every second. Is there a way to make it to where the game won’t lag a whole lot? I’m not sure as to what the solution would be, but I bet there’s something I can do. If you have an idea, please let me know. Have a wonderful day!

3 Likes

You can set the parts networkowner to someone. This makes it so parts physics are rendered on their side. Don’t reccomend doing this too important parts cause it can cause exploiter problems but the random colored bricks seem fine.

1 Like

if possible anchor the parts when they finish moving and disable collisions, cantouch, castshadows

1 Like

How exactly would that work? Can you tweak my code to make it work? Thank you!

local part = script.Parent

part.BrickColor = BrickColor.random()

part.Touched:Connect(function(hit)
	local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if not Player then return end
	
	local leaderstats = Player:WaitForChild("leaderstats")
	leaderstats.Parts.Value += 1
	part:Destroy()
end)