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 » Scripters
Home Search
 

Re: local p = Instance.new("Part",workspace) print(p) p:remove() print(p) --> Part  Part

Previous Thread :: Next Thread 
Emess is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
NecroBumpist is not online. NecroBumpist
Joined: 12 Sep 2010
Total Posts: 4198
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
nickmaster24 is not online. nickmaster24
Joined: 04 Oct 2008
Total Posts: 8906
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 is not online. 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
nickmaster24 is not online. nickmaster24
Joined: 04 Oct 2008
Total Posts: 8906
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 is not online. 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
nickmaster24 is not online. nickmaster24
Joined: 04 Oct 2008
Total Posts: 8906
11 Aug 2011 08:16 PM
What about:

_G.["clone"..serial] = object

??????????????????

~Big brother is watching~
Report Abuse
sncplay42 is not online. sncplay42
Joined: 27 Nov 2008
Total Posts: 11891
11 Aug 2011 08:18 PM
_G doesn't save.
Report Abuse
nightname is not online. 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
bunnybunn264 is not online. bunnybunn264
Joined: 04 Oct 2010
Total Posts: 5409
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 is not online. 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 is not online. NVI
Joined: 11 Jan 2009
Total Posts: 4744
11 Aug 2011 10:55 PM
collectgarbage()
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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