The number of times it fires per second varies which makes the problem even harder to pin down.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried the most simple loop possible and it still fires the incorrect amount of times. As you can see below, it printed “fired” the incorrect amount of times.
Output:
Please share more of your code with us, the issue is clearly not with the loop as it’s not reproducable by anyone else. Your logic elsewhere must be incorrect. Please also post code like so instead of screenshots:
```
code here
```
and this will produce:
function checkStatus()
if not Stats.Active.Value then return false end
if defenderScore.Value >= goal.Value then return false end
if raiderScore.Value >= goal.Value then return false end
if timeRemaining.Value <= 0 then return false end
return true
end
This will not produce what you have shown, there must be something you have done somewhere else that is creating this thread multiple times. As I said, please share the complete version of your code that contains this loop and we will be able to help more.
The issue where your loop is “repeating more times than expected” won’t have anything to do with the wait.
It produces what I showed. I don’t know why and it shouldn’t that’s why I posted this. The only reliable way to make the loop execute the correct amount of times is to remove the wait.
but his first loop is within a spawn() nothing else other then the “CheckStatus()” function can effect it. (and its not effecting it)
idk why his loop is going so fast considering the wait() will work fine. (even if ‘wait(1)’ only yields for 0.6 seconds instead of 1)
you also have to understand that roblox doesn’t actually let you run code concurrently, so the more things you have executing at once the more your time will be off by. (even if the code is in a different coroutine, someone correct me if im wrong though)
give this a read for more in depth information @ArtillarySquad
that isn’t the code he is using though, he is using the while loop to print the number value, so I don’t understand what you mean tbh.
@ArtillarySquad is your spawn() being created multiple times? this will run multiple loops back to back. (which means it’ll be printing to output too fast)
It is code he has replaced his code with to test, if you look at the post. This makes it evident that something else in code (that hasn’t been shared) is causing this issue.
EDIT: You even asked it yourself implicitly, asking if the rest of the code could possibly be creating this thread multiple times.