How would I make 1000+ parts move without lag?

Hi guys. I have 1000+ regular parts that I want to move in a game of mine, but the game lags pretty badly. Is there a way to make the lag stop? (No. Unions and folders sadly do not work, and there are too many parts to turn into one mesh.) I’m currently using RunService for it, but it still lags.

  1. What do you want to achieve? Moving 1000+ parts efficiently.

  2. What is the issue? Game lags very badly.

  3. What solutions have you tried so far? Using RunService. However, it does not work. The game sadly still lags.

If I am expecting the impossible here, please let me know. I’m asking this because I’ve seen a lot of games with complex meshes and many more have moving parts, and the game is lag-less. So, I figured that my goal is actually possible. Here is the script that I am currently using.

local Model = script.Parent
local PrimaryPart = Model.PrimaryPart -- Not important.
local PrepTime = script.PreparationTime -- Not important.
local StopRunning = false -- Not important.
local RunService = game:GetService("RunService")
local Goal = Model.WorldPivot.Position+Vector3.new(0, 15, 0)
local RunFunction

RunFunction = RunService.Heartbeat:Connect(function(Time)
	Model:PivotTo(Model.WorldPivot+Vector3.new(0, 0.5, 0))
	if (Model.WorldPivot.Position.Magnitude > Goal.Magnitude) then
		RunFunction:Disconnect()
	end
end)
2 Likes

Why do you need to move 1000+ parts? There’s probably at least some optimization you can do.

1 Like

can you turn it into multiple smaller meshes, then plug it into blender to remove excess verticies?

What kind of optimization? Telling me there’s probably “some optimization” that I can do does not help me. No offense, but how do you expect me to optimize it properly without telling me what to optimize?

is this a local or server script?

Server script. (character limitttttt)

just change it to a client script and it should solve some of the lag issues

on the server just update the position that client should move them to by firing to the client or just setting an attribute on the player and catching the signalchange

What’s the purpose of moving 1000+ parts? Is it meant to be continuous? Can you just teleport them the full distance at once? Is it an effect? etc.

this wont completely fix the issue but you should multiply the increment (.5) by the Time so if it lags the objet will move by more to compensate

Would it matter where I place the client script? Inside of a model? Put it in StarterCharacter? (I’m asking because I know there are limits when it comes to LocalScript’s.)

This would lag the player’s pc and make their fps choppy if not crash them.

It’s meant to stop after a few studs. If it reaches the goal’s magnitude, then it will stop. It’s supposed to move continuously until it reaches the goal.

Use TweenService then. If you need an example or help I’ll be happy to provide.

thats a terible idea, sending multiple remote events every frame will slow down the server so unbelievably much

TweenService lags it more. It also can’t Tween models which sucks a lot.

tweenservice is a memory hog, i wouldnt recommend using it here
you should also never run it on server, even with just one part

not every time just the position they need to move to thats why i suggested an attribute change

since you seem to be moving the objects quite fast, can you just move a different group of objects per frame and increase their movement speed

you can tween models with an anchored primarypart and all other parts unanchored and welded to it

you could also look into alignposition which will also give you the magnitude effect you are speaking of