[SOLVED] snake destroy terminal part body

hello,
i want make a variable in object, this variable is a timer,
to end of time is destroy only piece with variable to end.
But i have impression that if i write

set variable "life" of object "snakebody" + 1 if variable "life" of object "snakebody" > 30 destroy object "snakebody"
the pieces of body destroyed is more than one.
what is the solution? any idea?
thanks for read

*If you have multiple objects, and you want that just a specific one do something, you need to track the objects with, for example, a variable.

In the code you are sharing, every piece of the snake increase their life simultaneously, so you’re right: many pieces could be destroyed at once :slight_smile:

If you want to delete the last piece of the snake you could keep the tail with a variable “ID”=0 (to access it), this way the head would has “ID” = max = number of pieces -1, finally when you add a new tail, do + 1 to every piece before adding the tail, and do -1 to every piece before/after removing a tail.
If the snake has a initial size, just set the variables, for example head id = 3, neck? id=2, body id=1 and tail id=0.
Then:

Conditions: Variable "ID" of "snakebody" = 0 Actions: Do +1 to variable "life" of "snakebody"

Condition: Variable "life" of "snakebody" > 30 Actions: Delete object "snakebody" Consider all "snakebody" Do -1 to variable "ID" of "snakebody" (to set the new tail id=0)
I have not tested it, but surely you can get it to work (let me know if you need a “real” example) :wink:

i try , but not have succes,
if i can make variable in a body i can destroy if + of maximun variadle
but i’m confuse
thx lizard for response

i have solved with multiply of
life of body piece for maximum number of pieces created in a global variable
the script go well
my snake move in my web browser, fantastic!!!