|
| 10 May 2014 07:49 PM |
Both should do the same thing, remove parts named "SpecialPart"
option A:
while true do local p = game.Workspace:FindFirstChild("SpecialPart") if p then p:Destroy() else break end wait() end
option B:
local ws = game.Workspace:GetChildren() for i,v inpairs(ws) do if v.Name == "SpecialPart" then v:Destroy() end end |
|
|
| Report Abuse |
|
|
neo22894
|
  |
| Joined: 31 Aug 2007 |
| Total Posts: 63 |
|
| |
|
|
| 10 May 2014 07:58 PM |
| A will keep running forever, b will run once. Go B. Or make it so A only is true while your specialpart exists so it is as good as B. |
|
|
| Report Abuse |
|
|
|
| 10 May 2014 08:36 PM |
It breaks it if the part doesn't exist
while true do local p = game.Workspace:FindFirstChild("SpecialPart") if p then p:Destroy() else--right here break -- breaks it end wait() end
I guess it's a stalemate |
|
|
| Report Abuse |
|
|
|
| 10 May 2014 08:40 PM |
| Sorry, misunderstood break. For a test why not have both scripts run at once, but give them separate versions of specialpart, and have them print when removing it? I would think that with the wait() while true do would be slower, could be wrong though. |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 10 May 2014 08:53 PM |
while Workspace:FindFirstChild("SpecialPart") do Workspace.SpecialPart:Destroy() end |
|
|
| Report Abuse |
|
|
|
| 10 May 2014 08:53 PM |
| Use .ChildAdded not looping |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 10 May 2014 08:54 PM |
"Use .ChildAdded not looping"
From the looks of his scripts he doesn't want to constantly remove the "SpecialPart"'s Just remove them once then allow more, thats why he used "break" |
|
|
| Report Abuse |
|
|
|
| 10 May 2014 08:55 PM |
| Ohh, sorry read that wrong. |
|
|
| Report Abuse |
|
|
|
| 10 May 2014 09:10 PM |
128 is right, it's a one time removal thing. I tested it in a game, where there are 1,000 normal parts, 100 parts to remove for A and another 100 to remove for b. Total of 1,200 parts.
B is faster, because A has a wait.
But possibly A would have been more efficient if it had no wait, since it isn't checking every part in workspace. |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 10 May 2014 10:15 PM |
| Why not just use the one I posted? |
|
|
| Report Abuse |
|
|