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

How do i stop the number of Instances in the World from growing uncontrollably?

Asked by
Nogalo 148
7 years ago

I'm using a script to spawn clones of a part from server storage. The script works perfectly the problem is that for every part spawned 12 instances are added to the World and for every part destroyed by Debris service 2 are subtracted resulting in the number of instances growing forever which of course causes performance issues as that number gets bigger and i'm assuming if i left it running long enough it would crash.How can i stop this from happening?

Thanks for your time

local explosionPart = game.ServerStorage.GiantBoulder
local explosionPartDropHeight = 260

local function createExplosionPartCopy()
    local explosionPartCopy = explosionPart:Clone()
    explosionPartCopy.Parent = game.Workspace
    local xPosition = math.random(-100,100)
    local zPosition = math.random(-100,100)
    explosionPartCopy.Position = Vector3.new(xPosition, explosionPartDropHeight, zPosition)
    return explosionPartCopy
end

while wait(1) do
    game.Debris:AddItem(createExplosionPartCopy(), 11.4)
end
0
Have you let it run for a minute or so to make sure it doesn't stabilize at some point? What instances are getting deleted and what aren't? Unrelated, you might want to parent the part after you set up the properties, due to performance reasons, according to roblox. GoldenPhysics 474 — 7y
0
i've let it run for quite a bit and i've seen it climb from 38k that it was at the start to a whopping 60k before i stopped running Nogalo 148 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
local explosionPart = game.ServerStorage.GiantBoulder
local explosionPartDropHeight = 260

local function createExplosionPartCopy()
    local explosionPartCopy = explosionPart:Clone()
    explosionPartCopy.Parent = game.Workspace
    local xPosition = math.random(-100,100)
    local zPosition = math.random(-100,100)
    explosionPartCopy.Position = Vector3.new(xPosition, explosionPartDropHeight, zPosition)
    return explosionPartCopy
end

while wait(1) do
    Create = createExplosionPartCopy()
    game.Debris:AddItem(Create, 11.4)
end

If i understand from what your saying, its not deleting the proper ammount of items, right? Im not sure if this works, but it might.

0
The parts that are spawned disappear as they should but the number of Instances keeps piling on endlessly Nogalo 148 — 7y
0
Damn idk then studio bug? Abstract_Life 65 — 7y
Ad

Answer this question