Clones not deleting

id: 750679

category: Help with Scripts

posts: 7

Hi, so my project has a sprite where it creates clones of itself, and when it receives a broadcast, it's supposed to delete. For some reason it won't delete.
deck26 deck26 loading
So share the project please so we don't have to guess.

Purpleowlelliot wrote:

Hi, so my project has a sprite where it creates clones of itself, and when it receives a broadcast, it's supposed to delete. For some reason it won't delete.

I'm pretty sure you cannot delete a clone via a broadcast message. The code won't work if it looks something like this:

when I receive [Message v]
delete this clone

I would suggest setting a variable to delete the clone, something like this should work:

when I start as a clone
forever
if <(Delete Clone?) = [True]> then
delete this clone
end
end
Anhkv Anhkv loading

Purpleowlelliot wrote:

Hi, so my project has a sprite where it creates clones of itself, and when it receives a broadcast, it's supposed to delete. For some reason it won't delete.
Use This:
when I start as a clone
set [Delete Clone v] to [Yes]
when green flag clicked
forever
if <(Delete Clone) = [Yes]> then
Delete Clone




else

end
end
define Delete Clone
delete this clone
Let me know if this was useful.
mumu245 mumu245 loading

Cool_Dude2022 wrote:

(#3)

Purpleowlelliot wrote:

Hi, so my project has a sprite where it creates clones of itself, and when it receives a broadcast, it's supposed to delete. For some reason it won't delete.

I'm pretty sure you cannot delete a clone via a broadcast message. The code won't work if it looks something like this:

when I receive [Message v]
delete this clone

I would suggest setting a variable to delete the clone, something like this should work:

when I start as a clone
forever
if <(Delete Clone?) = [True]> then
delete this clone
end
end
Yes you can delete clones from a broadcast. I just tried it.
mumu245 mumu245 loading
Please, post the part of the code that is behaving weirdly so we can help you.
For some reason even when i bring out the delete this clone block and press it it does not delete.
Here is the link: https://scratch.mit.edu/projects/961161093/ It was working before, i don't know why it isn't now. If you find an error in my code, please tell me.