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

How to make script.Parent:Remove() more efficient?

Asked by 7 years ago

So am working on a Sinking Ship Simulator and I want to make my scripts more efficient instead of having tons of bricks under the unanchored ship model that have this script in them:

wait (195)
script.Parent:Remove()

What would be a more efficient script that would move the ship without needing this script or bricks under the ship?

0
What? Also, you should use :Destroy() Instead of Remove because remove is deprecated. User#11440 120 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

A good solution would be to put all the bricks you want to remove in a model and call the Destroy method on that model.

You'd end up with mostly the same script, though since you don't need to use the model or parts again you should use Destroy instead of Remove

wait(195)
script.Parent:Destroy()

That would eliminate having to put multiple scripts in every part.

0
Great answer! So glad someone came up with this great idea. User#11440 120 — 7y
1
Even better, you can simply loop through all the parts and destroy each one, instead of putting an individual script in each. GoldenPhysics 474 — 7y
0
How would I loop it? BunnyFilms1 297 — 7y
Ad

Answer this question