Adding value to a bar

Im trying to change an objects behavior so that when it’s clicked on, the object is destroyed and the value of a bar goes up by one. So far i have a mouse click trigger function, which adds to a number, which goes into the value of a bar. My problem is that when you click the object (its i being destroyed) the bar disappears. I appreciate any help I can get.

When an object uses “destroyer” it, along with all of its behaviors are removed from the level. So the bar disappears because it’s in a the object that is destroyed, so it goes too.

A way around this is to have a “scoreboard” object.

Use the Message/Mailbox to trigger the bar in its own object.

How to use a mailbox:

Have a message from an object (the object being clicked in this case) Set it to something easy to remember, and set the target to the scoreboard object/the object with the mailbox.

Connect any trigger (or mousclick in this case) to the message.

In the scoreboard object:

Add a mailbox, instead of being under components like message, it is under triggers.

Make sure it is set to exactly the same thing as the message was set to.

When the message is triggered, the mailbox will get it and trigger.

Basically, think of messages/mailboxes as invisible wires that go through objects

The bar belongs to the object. So when you destroy the object, you destroy the bar too. There isn’t a solution to let the bar stay with the destroyer behavior. So you have to create a new object with the bar in it so it won’t be destroyed. And you have to send a message (with the message behavior) to the object with the bar to add the value to the bar. You can receive messages with the mailbox behavior.

This is just a simple example to send the message:
[Mouseclick] --> [Message (send to object with the bar) ("Hello")]
You may change the “Hello” to everything you want. But the mailbox text has to be the same.

In the object with the bar:
[Mailbox ("Hello")] --> add value to bar

This is just what jngthree said. I just want to say it in my own words.

Tell us if you have any problems :slight_smile: