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

How do to destroy instances?

Ive tried to create a lag test game for roblox but im struggling to destroy once its been created, ive tried everything but it still wont work

Heres the code:

"wait(0.0000001) local LagPart1 = Instance.new("Part") LagPart1.BrickColor = BrickColor.new("Institutional white") LagPart1.Material = ("ForceField") LagPart1.Parent = game.Workspace LagPart1.Position = Vector3.new(12, 61.5, 5) LagPart1.Name = "LagParts" LagPart1.Size = Vector3.new(6,6,6)"

"Reset.MouseButton1Up:Connect(function() Reset1 = true workspace:WaitForChild(LagPart1):Destroy()

end)"

2 comments

0

Feeding an instance to WaitForChild is your problem. WaitForChild only accepts strings as its first parameter. Replace the LagPart1 variable with "LagPart1" as a string instead.

0

still doesnt work

1 answer

If you really wants to wait for a zeptosecond or the minimum second, consider changing to wait(). It takes 0.0002 seconds (I'm not sure I heard someone say it is)

You can clone an model and store all the parts inside, when you want to destroy all, destroy the model. It will be easier and straightforward.

1 comment

0

HOLD ON! PLEASE WAIT ATLEAST 0.15 SECONDS BEFORE CLONING ANOTHER INSTANCE / PART OR YOUR ROBLOX STUDIO WILL CRY FOR HELP

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