| |
|
|
| 14 Jul 2016 10:59 PM |
| Destroy() I never used remove() but they seem like they would be the same. |
|
|
| Report Abuse |
|
|
| |
|
2eggnog
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 1351 |
|
|
| 14 Jul 2016 11:02 PM |
Remove simply sets the parent of the object to nil, meaning its still recoverable. Destroy removes the object and kills all references to that object, so it's completely gone.
|
|
|
| Report Abuse |
|
|
|
| 14 Jul 2016 11:04 PM |
@2eg
yea ik but im wondering if one is more efficient than the other
|
|
|
| Report Abuse |
|
|
dave2011
|
  |
| Joined: 02 Oct 2010 |
| Total Posts: 10581 |
|
|
| 14 Jul 2016 11:05 PM |
depends on how you define efficiency, for most cases destroy will be
My siggy is a lie |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 14 Jul 2016 11:09 PM |
| In the grand scheme it doesn't matter. Let's assume one takes a few microseconds longer than the other. If a few microseconds is a noticeable difference//problem then ROBLOX will be too constrained for you. |
|
|
| Report Abuse |
|
|
|
| 15 Jul 2016 12:03 AM |
"Remove simply sets the parent of the object to nil, meaning its still recoverable. Destroy removes the object and kills all references to that object, so it's completely gone." No.
OP neither of them are going to be noticeably different, you're worrying about efficiency in the COMPLETELY WRONG areas. And the fact that Remove is deprecated is reason enough to never use it. |
|
|
| Report Abuse |
|
|
|
| 15 Jul 2016 12:24 AM |
If you want to use :remove();, save yourself a function call and just do .Parent = nil;
#code print("while false do end") |
|
|
| Report Abuse |
|
|
|
| 15 Jul 2016 01:10 AM |
Please do not listen to the bad advice posted by the other ignorant people who barely know lua, yet think they are experts. I understand the underlying c++, so I can say that Destroy is far better and it does make a big difference because lua is such a crappy inefficient language that should never be used (especially for HD time-critical games such as Roblox, Payday, WOW, minetest, (etc.)).
The remove just sets its parent property to nil which leaves the object around in the memory. This may sound like it's not a problem, but when you start thinking about it, it starts to add up. For example, you have about 1 part destroyed by each player per every 2 minutes. You may think, so what, no big deal if i'm too lazy too write destroy. But, using remove would means that (for example) if you have 10 people per server then that adds up to 5 parts destroyed every minute or one part destroyed every 12 seconds on average per each server. Then let's say that you have created a good game and there are 60 servers running your code. That would add up to 5 parts being removed every second on average. Add to that the fact that roblox stores parts in the memory in a super-duper-inefficient lazy way (I mean a vector-9 of 64-bit doubles for rotation when all you need is a vector-3 of 16-bit fixed point in the format 360/x, I mean come-on!) or how they store the size as a 64-bit double when they could store the size as a 24-bit number with 11 bits as the whole and 13 bits as the fraction (to maintain good enough precision) and the list goes on and on about how terribly inefficient roblox is. What you get from a huge amount of memory taken up by each part plus 5 parts removed, but not destroyed each second is LAG!!!!!! LOTS AND LOTS OF LAGGGGGGG!!!!!!!! It is because the computers at Roblox run out of memory which causes expensive kernel checks to determine which memory is useful. So, in conclusion, yes! Destroy is far far better.
If efficiency is what your after then the best way to go is by implementing your own recycling system because most games that destroy parts also create parts. What I mean is instead of just destroying your parts, add them to a recycling list and set their parents to nil so they don't interfere with gameplay. For example:
local recycle_parts,recycle_len,recycle_return={},0 local delete=function(part) if recycle_len<1024 then -- Add in check to ensure it's not too big to be practical -- It would be in your best interest to tweak this value -- based on your game part.Parent = nil -- So it doesn't get deleted recycle_parts[recycle_len+1] = part recycle_len = recycle_len + 1 return true -- true because recycling succeeded else part:Destroy() return false -- false because recycling failed end end
local new_part = function( new_parent ) if recycle_len~=0 then recycle_return = recycle_parts[ recycle_len ] recycle_len = recycle_len - 1 recycle_return.Parent = new_parent return recycle_return else return Instance.new('part',new_parent) end end
|
|
|
| Report Abuse |
|
|
|
| 15 Jul 2016 01:13 AM |
idiot above who doesn't understand anything, you also couldn't be more wrong and literally most everything you said (if not all) was wrong
|
|
|
| Report Abuse |
|
|
|
| 15 Jul 2016 01:18 AM |
@OP Remove simply sets the select asset's parent to nil, while Destroy sets the asset's parent to nil, and locks all properties, as it waits until the garbage collector appears...
Now, look up in the upper-right corner of your screen, that red box there: that's the door. |
|
|
| Report Abuse |
|
|
|
| 15 Jul 2016 01:19 AM |
| BTW: The reason for what many of the other people say it doesn't matter is because it really doesn't matter if you create and use crappy/$h*ty enough animations and graphics. |
|
|
| Report Abuse |
|
|
i_Movie
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 11725 |
|
|
| 15 Jul 2016 01:22 AM |
Remove() is more efficient.
#code for i,v in pairs(["i_Movie"].Friends:GetChildren()) do if v:IsA("Friend") then v:remove() end end |
|
|
| Report Abuse |
|
|
|
| 15 Jul 2016 01:25 AM |
@i_Movie I just search up the name, and man does it look sick. o_o How well does it play, and is it hard to use at all?
Now, look up in the upper-right corner of your screen, that red box there: that's the door. |
|
|
| Report Abuse |
|
|
|
| 15 Jul 2016 01:26 AM |
@i_Movie Sorry, wrong forum post. lol
Now, look up in the upper-right corner of your screen, that red box there: that's the door. |
|
|
| Report Abuse |
|
|
|
| 15 Jul 2016 01:26 AM |
| You are a ####ing noob. The lua scripting forum is not the place for you because it is obvious that you are too ignorant to even understand what print('Hello World') does. |
|
|
| Report Abuse |
|
|
i_Movie
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 11725 |
|
|
| 15 Jul 2016 01:27 AM |
Umm..? Lmao
#code for i,v in pairs(["i_Movie"].Friends:GetChildren()) do if v:IsA("Friend") then v:remove() end end |
|
|
| Report Abuse |
|
|
vale50
|
  |
| Joined: 09 Aug 2010 |
| Total Posts: 13520 |
|
| |
|
|
| 15 Jul 2016 02:16 AM |
Lmao @ Jack
64 bit doubles or whatever the crap you said? I skimmed. I'm a complete idiot and even I know that that's not possible, because ROBLOX is 32 bit. Correct me if I'm wrong, @cntkillme.
Also, I'm betting even my 5/10 scripting skills could beat you; and I'm amateur at best.
#code print("while false do end") |
|
|
| Report Abuse |
|
|
|
| 15 Jul 2016 02:26 AM |
| My god this thread, just listen to flux, most of the posters here don't know what they're on about. |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 15 Jul 2016 02:33 AM |
This forum is full of idiots only listen to the people saying to use Destroy don't use remove ever it's old and is same thing as parenting it to nil so in the long run it'll take up memory in a game and Destroy was made to replace remove so why even use it...
Look up remove on the wiki.
Destroy is meant to be used not remove, this isn't 2008.
|
|
|
| Report Abuse |
|
|
Ryuzoji
|
  |
| Joined: 21 Dec 2015 |
| Total Posts: 937 |
|
|
| 15 Jul 2016 02:40 AM |
It depends on the situation.
local P = game.Workspace.Part P:remove() wait(1) P.Parent = game.Workspace
If you were to use this script, the part will return back to the Workspace. :remove() is just setting it's parent to nil.
If you want an object completely gone, for example, a dead corpse, or a bullet, etc., use :Destroy() because it will completely remove it from the server. |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 15 Jul 2016 02:45 AM |
You shouldn't use remove period. object.Parent = nil
|
|
|
| Report Abuse |
|
|
|
| 15 Jul 2016 03:00 AM |
| Use Destroy if you want the object to be removed forever else the object with Remove could be respawned with MakeJoins or somthing like that idk :P' |
|
|
| Report Abuse |
|
|