The title says basically everything
Place this code in the default script of the object that produces the clones:
if(this.isClone){
this.remove();
}
Let me know if it works
technically this removes clones when you enter the frame, not exit, but visually it is the same.
Correct.
For exiting the frame, you would need to use the unload script, but the unload script currently has a bug
I put that in the Load script for the parent object but it just deletes the clones as soon as they spawn, If I put it in the Default script for the parent object the same thing happens. I want to remove the clones upon entering the frame in the Main Timeline but still be able to spawn the clones later after the initial ones get removed
My bad, the code I gave you only works in the unload script, so try this instead:
if(this.Delete&&this.isClone)
this.remove();
this.Delete=true;
Place this code in the default script, and let me know if it works
Thank you, it worked! This is optional but can you explain how the code works so I can learn the code instead of just learning Ctrl + C Ctrl + V, Thanks in advance and thanks right now!
Sure, so here’s the code
What the code says is:
if this object is a clone and this.Delete is true, then remove this object.
Set this.Delete to true.
In the code, I didn’t define “this.Delete” before I checked to see if it’s set to true, therefore “this.Delete” was set to undefined, and not true. So the object didn’t remove itself.
In the second line, I set “this.Delete” to true, so it had an actual value of “true” the next time the default script was run, and therefore, the clones removed themselves.
Extra
this.isClone = is set to true if this object is a clone
this.remove() = a function to remove this object
this.Delete = a variable that is attached to this object (it’s set to “undefined” by default)
okay so && is just a fancy was of doing if(conditional expression){
if(different conditional expression){
thing to do}?
yep, && technically means “and” and you can replace it with if(something){
if(another_thing){
// Code
}
}
“&&
” = and if(something AND something){
// Code
}
“||
” = or if(something OR something){
// Code
}
“!
” = not if(NOT something){
// Code
}
you can always cycle trough yourObject.clones that is an array of all the clones of yourObject clip.