Thank you for all the suggestion, 1 more thing is regarding the timer, it seems like everytime I restart the game there seems to be another thread in the schedule list.
Like an example below, saying I have a loop to spawn enemies, so by right the enemy will spawn everytime when respawnTime reach 0. but after I restart the game, it will spawn before reaching 0, it felt as there were another thread behind.
var respawnTime = -1;
while(!gameOverFlag)
{
respawnTime -= time_step;
showTimeOnScreen = respawnTime;
if(respawnTime <= 0)
{
respawnTime = 200;
}
wait(1);
}
So my question here now is, if it is possible to clear the threads in the schedule list when I restart the game?
Thanks for reading.