Emess
|
  |
| Joined: 01 Apr 2010 |
| Total Posts: 13331 |
|
|
| 11 Aug 2011 05:55 PM |
??? Why does it return "Part" after I remove it? |
|
|
| Report Abuse |
|
|
booing
|
  |
| Joined: 04 May 2009 |
| Total Posts: 6594 |
|
|
| 11 Aug 2011 05:57 PM |
cuz part is part p = Instance.new("Part",workspace) p:remove() p.Parent = workspace U haz a part |
|
|
| Report Abuse |
|
|
xSIXx
|
  |
| Joined: 06 Aug 2010 |
| Total Posts: 9202 |
|
|
| 11 Aug 2011 06:05 PM |
| Just because you set the Parent to nil does not mean it's gone forever. |
|
|
| Report Abuse |
|
|
blocco
|
  |
| Joined: 14 Aug 2008 |
| Total Posts: 29474 |
|
|
| 11 Aug 2011 06:09 PM |
| YOU STILL HAVE A REFERENCE TO PART FOO' |
|
|
| Report Abuse |
|
|
nightname
|
  |
| Joined: 10 Jun 2008 |
| Total Posts: 8960 |
|
|
| 11 Aug 2011 06:10 PM |
Its because the remove function just moves the part to nil.
local p = Instance.new("Part", workspace) print(p) p:remove() print(p)
Would print:
> Part > Part
And then we can could this:
p.Parent = workspace
and it will return back to the workspace.
Now if we did this:
local p = Instance.new("Part", workspace) print(p) p.Parent = nil p = nil print(p)
> Part > nil
|
|
|
| Report Abuse |
|
|
Emess
|
  |
| Joined: 01 Apr 2010 |
| Total Posts: 13331 |
|
|
| 11 Aug 2011 06:16 PM |
@nightname if I put p into a model, wouldn't saying p.Parent = nil bring the model to nil? |
|
|
| Report Abuse |
|
|
nightname
|
  |
| Joined: 10 Jun 2008 |
| Total Posts: 8960 |
|
|
| 11 Aug 2011 06:24 PM |
"if I put p into a model, wouldn't saying p.Parent = nil bring the model to nil?"
No it wouldn't. That is not how Lua works... If I wanted to make model nil, then I would have to do:
p.Parent.Parent = nil
|
|
|
| Report Abuse |
|
|
Shobobo99
|
  |
| Joined: 30 Dec 2008 |
| Total Posts: 5754 |
|
|
| 11 Aug 2011 07:20 PM |
| Parent could be refering to the parent of the object or the parent object. |
|
|
| Report Abuse |
|
|
nightname
|
  |
| Joined: 10 Jun 2008 |
| Total Posts: 8960 |
|
|
| 11 Aug 2011 07:23 PM |
"Parent could be refering to the parent of the object or the parent object."
Parent references where the part is stationed at. |
|
|
| Report Abuse |
|
|
|
| 11 Aug 2011 07:24 PM |
Because it's only been parented to nil. You still have a reference to it. The garbage collector isn't going to touch it yet.
-NecroBumpist, Master of Lua, Writer of Wikis |
|
|
| Report Abuse |
|
|
|
| 11 Aug 2011 07:57 PM |
Wait, so as long as you keep a reference, you could keep tycoon clones and stuff in nil instead of Lighting?
~Big brother is watching~ |
|
|
| Report Abuse |
|
|
sncplay42
|
  |
| Joined: 27 Nov 2008 |
| Total Posts: 11891 |
|
|
| 11 Aug 2011 07:58 PM |
@nick yes.
The only reason to put them into lighting is so they save. |
|
|
| Report Abuse |
|
|
|
| 11 Aug 2011 08:01 PM |
"so they save"
Object value with the value of the object in nil?
~Big brother is watching~ |
|
|
| Report Abuse |
|
|
sncplay42
|
  |
| Joined: 27 Nov 2008 |
| Total Posts: 11891 |
|
|
| 11 Aug 2011 08:15 PM |
| ObjectValues only save their value if it's part of the game/model being saved |
|
|
| Report Abuse |
|
|
|
| 11 Aug 2011 08:16 PM |
What about:
_G.["clone"..serial] = object
??????????????????
~Big brother is watching~ |
|
|
| Report Abuse |
|
|
sncplay42
|
  |
| Joined: 27 Nov 2008 |
| Total Posts: 11891 |
|
| |
|
nightname
|
  |
| Joined: 10 Jun 2008 |
| Total Posts: 8960 |
|
|
| 11 Aug 2011 08:19 PM |
"_G.["clone"..serial] = object"
It will be removed when the game runs again. That is why the ObjectValue is more useful than you think.
|
|
|
| Report Abuse |
|
|
|
| 11 Aug 2011 09:05 PM |
to really remove your part, um, you'll need to lose scope of it. So,
do local p = Instance.new("Part", Workspace) p.Parent = nil end print ( p.Name ) ==> errors about attempting to index nil value |
|
|
| Report Abuse |
|
|
Razer100
|
  |
| Joined: 28 Aug 2009 |
| Total Posts: 8066 |
|
|
| 11 Aug 2011 10:47 PM |
local p = Instance.new("Part", workspace) print(p) p:remove() print(p)
All it does is print (p) twice, removing it does not make it nill
You need to make " p = nil"
print(p) p = nil print(p) |
|
|
| Report Abuse |
|
|
NVI
|
  |
| Joined: 11 Jan 2009 |
| Total Posts: 4744 |
|
| |
|
|
| 11 Aug 2011 11:51 PM |
"collectgarbage()"
Didn't ROBLOX admins remove that function? You need to wait for an automatic garbage collection cycle to collect the object, once all references to it have been removed, you can't do it manually.
Object stay in memory as long as there is still a reference to them.
To delete an object from the memory, you must remove every reference in it and parent it to nil. |
|
|
| Report Abuse |
|
|