I can't stop my events from happening once someone won the game

So I have been making a game where people get swords once the round starts and random events happens every 7 seconds. The events have been working perfectly but the only issue I have is to stop the events; once there is only one player left, It should say that he won but no, the events kept on running. I have tried everything that I can (keep in mind I’m a pretty new scripter so I’m not that smart) but I couldn’t make it stop . Can somebody please fix the issue? It will be greatly appreciated!

Here’s The Script:
erro

1 Like

Question, do you need the repeat loop to yield?

Try wrapping the loop with task.spawn(function() end) and check if it breaks anything.

If it doesn’t ruin your script, you can just store the thread (task.spawn) in a variable., then just cancel the thread with task.cancel() at the end of the game.

thanks for replying, yeah I’m just going to test it out now

I have just tried out your method and It doesn’t seem to work, now the script doesn’t repeat the events, but only does the events once. And yet again, when there is only one player, it doesn’t end the game. Are there any more methods to solve this, it be once again greatly appreciated!

Here’s what I did:

1 Like

never mind, I figured out a solution for this, not with task.spawn() but I just had to wrap the repeat loop all over the round script; but thank you for attempting to help me, at least I unlocked the feeling when you finally debugged a code :slight_smile:

That’s not really how you do it-

But hey, you already found a solution. Good job.

When you loose do you get kicked / leave? If not that’s the reason you script isn’t working