Script keeps looping even after being destroyed

Maybe add another if statement like:
if ScriptIsDestroyed == true then break end;

Right before the script is destroyed:
ScriptIsDestroyed = true;

1 Like

I’ll try something like that real quick and see if that works

My solution should be considered a short-fix until you figure out what else is causing it.

1 Like

Try adding it to Debris?I know this probably doesnt help,but it doesnt cost try!

1 Like

Also, never used or heard of coroutines, i’ll do some research on that

Yeah as @Chaddaking said, you could have some boolean value and implement your while loop that way

while (ScriptIsDestroyed) do
    wait(rate.Value)
    --do the rest of the stuff
end
1 Like

this is a good tutorial on coroutines in my opinion

1 Like

I’ve just added a bool value called “IsDestroyed” into each creature’s grow script. And when the creature grows it changes the value to true and breaks the loop if the value is true. This worked, but like Chaddaking said this should be a temporary fix until I figure out what was causing this.

1 Like

Nah it’s not rly one of those fast fixes until you figure out what was causing it, everything’s fine if you’re using it.

1 Like

Anyways, thanks for the help everyone!

1 Like