I followed the tutorial by roblox on how to make a round based game, but only the randomly falling objects part and modified it a bit
(the tutorial is https://www.youtube.com/watch?v=rsTN0DppMaA&list=PLuEQ5BB-Z1PJ4JIDXpttxuvCzJMeIqzMi&index=17)
However when I leave the game open on test for a while I notice lag build up and Roblox studio freezes proportionately to how long i leave it open when i try to end the test. My assumption then is, despite these parts falling out of the world IE Despawning, as well as having a :Destroy() 1.5 seconds after they come to life on them, Roblox is holding onto some information about them causing something I assume is similar to a memory leak.
Heres my code for spawning and randomly dispersing the rain:
local rainDrop = game.ServerStorage.RainDrop local function createRainDropCopy() local rainDropCopy = rainDrop:Clone() rainDropCopy.Parent = game.Workspace local xPosition = math.random(-50, 50) local zPosition = math.random(-50, 50) local yPosition = math.random(90, 150) rainDropCopy.Position = Vector3.new(xPosition,yPosition,zPosition) end
while true do createRainDropCopy() wait(0.1)
end
And heres my code for despawning them:
wait(1.5) local rainDrop = script.Parent rainDrop:Destroy()
TLDR: When I use :Destroy() to delete my raindrops so they dont stick around, roblox still seems to hold onto some information about them causing the game to get laggier and laggier the longer its open because more of them keep building up.
Curious if anyone has any ideas on how to solve this, and yes im aware this is an inefficient way of doing this so I am also open to suggestions of alternative methods.
Regardless thank you for reading! :)

2 comments
Figured I would restate here: Im aware this is not efficient, I am open to alternatives as well as solutions!
perhaps the problem is that the loops are stacking? im not too sure try doing script:Destroy() at the end too