How to script drops for tycoon well

Once I add that the memory stays the same, and the server’s ping does not rise whatsoever.

If you move the line I sent before to line 33 (first line of getDrop), does it have any effect?

(Going to cycle through each function to narrow down where the issue may be occuring)

It does not have effect. I definitely think it is the :Drop() function that is causing the memory leak

Yeah, it is definitely the to do with the drop function. Currently, I’m trying to determine whether it is immediately within the function, or if it is a result of another function call.

Alright, I’ll try to see if I can figure anything out

I don’t know if your storing system is actually functional.

Remove the if true then return stuff. At the start of the getDrop function, can you please add

print(#TycoonInfo.PooledDrops[player])

and let me know what the output is

(it may error)

nice job on pinning down the memory leak!

i probably couldn’t do that myself


Essentially consistent 0’s, with some 1s here and there. I think the highest I saw was 4.

Interesting.

If you replace the print with

print(#ServerStorage.PooledDrops:GetChildren())

what does it output now?


Essentially the same to be honest. It does show numbers other than 0 more often, though.

Your storing system should be working correctly then.

If you put

if true then return end

on line 66, does it have any impact on lag? (this is going to remove the else part of the script)

Game doesn’t lag at all, but that’s because nothing spawns if I remove the else statement. The else statement is where I generate a new drop if there isn’t one ready to be used in the PooledDrops folder in ServerStorage.

Edit: Looking at my console, there is an “unknown” scrip that is running significantly more than the others, and is constantly spiking

I guess that would make sense xD

If you remove the if true then return thing, and just make it print some text (in the same location, so line 66) how many times does it print out


It’s constantly printing out, since there are many droppers in the game, and no pooled drops.

After a minute or so does it continue to flood the output?

I made it so that it spawns the drops, and even with drops in workspace it keeps printing “creating new drop.” After a while, it should stop printing that as its recycling them.

I’m not able to be on my PC anymore, let me try and see on my laptop (its pretty bad)

Yeah it continues to flood the output, but I think that is because the drops are added to the PooledDrops folder after they have been collected at the end of the conveyor belt. Because they are falling and moving so slowly, they never make it to the end of the conveyor belt, and thus infinite drops are being made. I feel as if there should be some solution that I’m missing

You can try setting a hard limit on spawned objects. If the limit is reached, don’t attempt to spawn a new object and instead just award the player the expected amount of money.

How would I calculate this limit? Also, have you diagnosed why the memory leak is happening?