Can cloned object from ChildRemoved :destroy instance be reused?

What I’m gonna do is recreate an instance after it’s destroyed with ChildRemoved and clone
Will the cloned instance’s parent be unlocked?
Also will the clone function copy the instance’s child as well?

--A folder with an instance inside that include an instance named "Child" inside
Folder.ChildRemoved:Connect(function(Object)
    local NewObject = Object:Clone();
    NewObject.Parent = Folder; --Question 1: Will this work?
    print(NewObject.Child.Name); --Question 2: Will this work?
end;

Folders do not have a locked or unlocked property so I’m not sure what you mean by the parent being unlocked

Also about your question if this will work or not it will need to be on the server side (the object and the parent )if it’s a server script and if it is yes both will work

The Destroy function will lock an instance’s parent, and clear all the child inside of it, what I’m trying to say is that, if I clone the instance when it’s destroyed using ChildRemoved then will the cloned instance’s parent comes out as locked or not? And will the child pass through to the cloned instance?

Wait how would it be locked if folders don’t have a locked property if that’s true why not set .locked = false ?

Instance.ChildRemoved returns a reference of the child removed, and since that child would still have its Archivable property enabled, you would be able to clone it I would think, but you would not be able to do anything with it because its Parent property would be locked and nil. This is the same for its descendants since :Destroy is called on them too, which also means that there is not a deep copy of the instance passed to a future :Clone, if that matters at all.

It’s usually better to keep a copy of the folder somewhere in ServerStorage or ReplicatedStorage and clone it from there, as your method could get really hacky.

1 Like

Also I don’t think the child will pass unless u reclone the object on the server or it still exists on the server

The destroy function lock an instance’s parent, The instance that’s getting destroyed is the one inside the folder if I’m not clear

Yea what the other dev mentioned I would destroy it and make sure a copy is still in replicatedstorage and then clone it from there :slight_smile:

What I’m currently trying to achieve is create a part that let a player control it’s bodymovers for the other client to listen, but if the part is destroyed from exploiting by moving the part below FallenDestroyHeight will I be able to clone it back into the folder fully intact?

Yes because it would only be destroyed on the client . As long as there is a server object intact it will still function . Unless ur running this on a localscript only which would be bad practice

SetNetworkOwner is included to the player by the way, and this’s running on server

Yea then as long as the cloning happens on the server side it will work bc exploiters can’t affect the server unless they use remotes(functions or events)

What I mean is, the server is the one create the part including all bodymovers as values in it, and give the part’s networkownership to the player, which mean the player can control the bodymovers and the Part, if the player exploit and move the Part below DestroyHeight then that Part will be destroyed in the server itself, and now I’m trying to use ChildRemoved on the folder that store the Part to bring that destroyed part back again using clone, but I don’t know if the server will be able to change the Cloned Part parent back to the folder including it’s childs

I think it be better if u verified that the player is able to move it legitimately so this won’t happen by any chance is this a tool used to do what you intend regular users to do because you can always check if player is using that tool and if not don’t give them ownership because I think you might get an error if player gets the object destroyed . Another thing you could do is when doing the clone when checking if it’s removed is again clone from replicatedstorage the parent and the child

It’s a client to client connection used for the change that’s supposed to animate player’s waist and head to where the player’s looking at(and many possible similar feature), which mean I don’t have to secure it, but I have to create a safelock incase the part that is inside the folder for each player got destroyed by a possible method(Which is moving it below fallenpartdestroyheight) and I don’t know if the clone function will be able to recall the part and move it back to where it should be fully intact

Yea ur best bet is having backup parts in replicatedstorage for the server to replicate Incase this happens

Incase if it happen, the server will clone the backup Part and put that into the PhysicEvent folder, then the sender client and all the listener clients will automatically reconnect to the Part, but the problem is for a small window of time, if the listener client connects first, then it will apply the default value to what the function is intended to do [For example Bodymover named “MousePosition” with a vector3 value inside as (0, 0, 0) as a default backup value] after that the sender reconnects and change that value into what it’s supposed to be then the listener apply the value that’s not a default, which mean there will be a small time of unintended behavior for the listener client and if I’m going to try to make the server fills those values before putting it there, it’s not possible because the previous bodymovers are already disconnected from all references

You could use a repeat wait until the condition occurs so this doesn’t happen. Or you could just wait a few seconds ex : wait(3)

I think I might have to use DescendantRemoving, because this event fires before Destroy can do anything to the instance, anyway, thanks for all the people who helped

4 Likes