#would this script lag

1 messages · Page 1 of 1 (latest)

pine finch
#

i have a destruction system that duplicates parts into smaller parts to make debree, the used part i just to check if its a normal part or a debree part, this is for lights to turn black. since i have prob ten thousands of these scripts would it lag

    script:FindFirstChild("used"):Destroy()
else
    script.Parent.Color = Color3.new(0,0,0)

    for i,v in pairs(script.Parent:GetChildren()) do
        v:Destroy()
    end

end
placid walrus
cerulean thistleBOT
#

studio** You are now Level 21! **studio

placid walrus
#

I would recommend researching "Object Pooling".

pine finch
#

do they lag when they are inactive

#

or only when they fire

placid walrus
#

Probably only when they fire

pine finch
#

alr

#

they fire very rarely so it prob wont lag then

placid walrus
#

Well if its thousands then it will still lag.

pine finch
#

they only fire on player some interactions near players

placid walrus
#

Just research "Object Pooling". That might make the lag less. I can't really give you much info on that tho because I have never made such a system. But I know that its just instead of deleting and creating new parts you reuse them.

pine finch
#

i did and the system doesent operate in a way that this would be necessary in

placid walrus
pine finch
#

no i have thousands of objects already in a map with scripts

#

the duplicating is a part of a destruction system, the scripts fire if they are duplicated

#

if ur wondering about the destroy() part thats just to remove particles and light sources

placid walrus
#

Well you could reuse the duplicated parts or preload them.

pine finch
#

prob

#

i know what to do now but thx

grave zealot
pine finch
#

Why not? They are useless after the scipt runs

grave zealot
#

you only need a single module script