Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

best way to defeat lag caused with large part amount? [closed]

Asked by 4 years ago

so i have already asked for that but i explained it the wrong way. so my game is having a lag and im asking whats the best way to defeat the lag? here are some pictures of the lag:

http://prntscr.com/r48ajs

http://prntscr.com/r48avm

http://prntscr.com/r48b68

i have added a button that clears all ores but it doesnt really fix the glitch.

Any help will be appreciated

Closed as Not Constructive by Fragmentation123, Filipalla, User#23252, killerbrenden, and Ziffixture

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 4 years ago

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

0
partially okay, but what if a part needs to be there for visual purposes? this is not good advice User#23252 26 — 4y
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 InfinityDesign 280 — 4y
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. InfinityDesign 280 — 4y
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. InfinityDesign 280 — 4y
View all comments (6 more)
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. Ziffixture 6913 — 4y
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. InfinityDesign 280 — 4y
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 User#23252 26 — 4y
0
They're not reaching the end of the conveyor belt, as evident in the pictures. InfinityDesign 280 — 4y
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) User#23252 26 — 4y
0
I'm sorry, what? You're saying filling up memory and increasing ping is efficient? Ziffixture 6913 — 4y
Ad