How to stop a background task?

I use "launch say 'goal' for 2 sec". But when the user stops the game the message should disappear immediately. I tried to use "stop other scripts in sprite" but it does not work. How can I stop the background task?

Perhaps you could run the background task within a dedicated sprite (e.g. “Sprite(2)”), then:

untitled script pic (2)

"stop all but this script" works.

True, but stop [all but this script] stops all background scripts - is that is what you were actually looking for?

Is a background task a first-class value, which can be stored in a variable in order to stop just the stored task?

Scripts are first-class, so they can be stored in a variable or something else.
For background tasks I don't know. :confused:

AFAIK You can't get a ref to the launched task but techniques such as this may do what you want

untitled script pic - 2024-02-12T121602.947

AFAIK processes are not first-class (yet). That would be a useful feature, I think - though I couldn't say whether it's very complicated and/or has any undesirable consequences.

I have a solution now, but the forum does not allow me to include it in this post.

You could still try to explain it.

I am miffed that I am not allowed to include code examples although other people can do so.

People who are new to the forums don't immediately gain the ability to include code examples, it's just a precaution.

Its just to prevent spam from malicious actors - once you've read/posted a few more times - your trust level will go up

I can't help thinking that THIS SCRIPT or THIS CALLER or THIS CONTINUATION could be useful, but nothing that I tried worked. :~/

Did you obtain access to the code share facility yet? (like @me_the_super and @cymplecy wrote, it’s nothing personal).
If you actually found a sound approach to stopping a single background process, you would even be ahead of the Great Teacher himself :smiley: