generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: What will be faster/more efficient?

Previous Thread :: Next Thread 
TehIcyStar is not online. TehIcyStar
Joined: 07 Mar 2010
Total Posts: 1649
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 is not online. neo22894
Joined: 31 Aug 2007
Total Posts: 63
10 May 2014 07:52 PM
I VOTE B!!! GO B!!!!
Report Abuse
robertjh12 is not online. robertjh12
Joined: 24 Feb 2008
Total Posts: 601
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
TehIcyStar is not online. TehIcyStar
Joined: 07 Mar 2010
Total Posts: 1649
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
robertjh12 is not online. robertjh12
Joined: 24 Feb 2008
Total Posts: 601
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 is not online. 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
VirtualPrince is not online. VirtualPrince
Joined: 17 Oct 2013
Total Posts: 7386
10 May 2014 08:53 PM
Use .ChildAdded not looping
Report Abuse
128GB is not online. 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
VirtualPrince is not online. VirtualPrince
Joined: 17 Oct 2013
Total Posts: 7386
10 May 2014 08:55 PM
Ohh, sorry read that wrong.
Report Abuse
TehIcyStar is not online. TehIcyStar
Joined: 07 Mar 2010
Total Posts: 1649
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 is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
10 May 2014 10:15 PM
Why not just use the one I posted?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image