Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

best way to defeat lag caused with large part amount?

1 answer

You're using a ton of parts there. Not using as many is the simplest answer as far as alleviating lag.

You need to be cleaning up the parts on a timeout, meaning a set amount of time the part can be alive for, after this time you delete the part. You can easily achieve that with delay

-- in your part spawning code

local part = Instance.new('Part')
part.CFrame = dropper.CFrame

delay(5, function()
    part:Destroy()
end)

Some of the lag will be created by the physics calculations on the parts. You can help the server out by calling Part:SetNetworkOwnershipAuto()

Here's a little more info on what that's doing

10 comments

0

partially okay, but what if a part needs to be there for visual purposes? this is not good advice

1

You have so many parts that they're stacking up to the dropper, no room at all to make more. Parts need to not be there because they're breaking the game. https://image.prntscr.com/image/FB_zemRmSgKmu4WWIlF2GA.png

1

The timeout cleanup is something that every part dropper tycoon uses. Mostly because it removes parts that have fallen off the conveyor belt, but the total part count limit helps drastically with lag.

0

You only benefit from calling SetNetworkOwnershipAuto() on every part you spawn because you give the server the ability to offload the calculations if it's getting slowed down.

2

This is functional, however inefficient. You can schedule a removal of an Instance in one line without interrupting the thread through the Debris Service. game:GetService("Derbis"):AddItem(Part, 5). There are several possibilities for raising exceptions with the code above too, this will handle it all efficiently.

1

Very minimal impact compared to not timeout cleaning up parts at all tho. It's not a good situation to keep creating parts on an infinite loop without any guarantee they'll be cleaned up in a timely manner. The laws of physics set limits on how much game engines can handle, and you cannot exceed them no matter how badly you need it all for visual purposes.

0

well for droppers in tycoons, there is no need of a pile of parts, therefore, deleting the parts after reaching the end of a conveyor belt is the appropriate thing to do

0

They're not reaching the end of the conveyor belt, as evident in the pictures.

0

what i am saying is, its not a good idea to delete parts and then remake them.. yes, when don't need a part anymore you should delete it or put it in ServerStorage (but only if its customizations can't be fullfield in a script or the part is a template)

0

I'm sorry, what? You're saying filling up memory and increasing ping is efficient?

This discussion is preserved as it was. New answers, comments, and votes are closed.