Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Can using remove cause lag over time?

Asked by 9 years ago

Can using remove() cause lag over time? I was told that when you use the remove() event it doesn't completely erase all the data of whatever is removed whereas destroy() does and I was wondering if this is true and/or if using destroy() instead would make a difference. Any advice/thoughts would be very helpful, thanks!

2 answers

Log in to vote
0
Answered by 9 years ago

Remove() doesnt actually "Remove" it from your world, it just temporarily makes it nil. For Example

local part = Instance.new("Part", Workspace)
print(part.Parent)
--> Workspace

part:Remove()
print(part.Parent)
-- prints nil

part.Parent = Workspace
print(part.Parent)
-- print Workspace

As you can see here it just makes it nil for the moment, and it can be re-added just by simply defining a parent.

So for your question, it should not cause lagg. Though it is not complete gone, it is nil therefore it does not exist for it to be accessed, Meaning it cannot generate lagg for a player. Only way in which it can return is by re parenting it to workspace or otherwise. If you want to get rid of an object, the proper method to use is :Destroy() for it will completely remove the object from your world

0
False. Roblox doesn't just magically make the object "come back" when you reparent it. The object, in fact, won't be removed as long as there are references to it (which is how :Destroy() works, it removes references). What creates the illusion of it not existing is how it's not in the DataModel, and how you therefore can't find it through normal ways. But yes, the object will still exist if there gskw 1046 — 9y
0
are references to it, and can, in theory, cause lag by eating up RAM. gskw 1046 — 9y
0
@gskw You know you actually just proved him correct right? M39a9am3R 3210 — 9y
0
._. , if you think that my answer was not valid, even though you proved in your own words it was, why not answer for yourself instead of posting your incredible thinking koolkid8099 705 — 9y
Ad
Log in to vote
1
Answered by 9 years ago

The simple answer is normally no.

Using remove sets the Instance's parent to nil, but it still exists internally and can be reparented. It'll get gc'd at a later time, but it's not suggested to use it because it was deprecated in favour of Destroy for good reasons.

Answer this question