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

Help? in my Tycoon Droppers continue dropping at the same speed during lag

I'm making a tycoon with Fvii's tycoon kit, and I've made it to the point where theres so many droppers that if a clog happens, the dropped parts slow down, but the droppers still drop, cause more parts to appear. Thus the game lags and the drops dont make it to the collector. I need help making a script that every 120 seconds any parts named "DroppedPart" that have been in the workspace for less than 20 seconds will get removed.

Any help writting the script would be apreciated, thank you for your cooperation.

1 answer

You should really try to learn some scripting yourself and try to get a prototype working before posting here. However I'll offer 2 ideas for writing your code:

The first option is the debris service. It has a method called :AddItem(item, lifetime). It will automatically delete item after lifetime seconds have passed.

The second option is to use the delay(t, func) function. This will automatically fire function func after t seconds have passed. If you let function be one that deletes each part for you, you can accomplish your goal.

You mentioned, however, that you want the script to only delete parts every 120 seconds. In that case, I will direct your attention to option 2. This time, let t be 20, and let your function add the part to a table. On a separate loop, every 120 seconds, go through this table and delete everything in it.

Try to get a working prototype using these ideas and come back if you have questions. Perhaps you can even think of another way to script this, which would make this a much more beneficial exercise for you.

Hope this helps!

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