local gameStarted = tick()
repeat
wait(.5)
until (tick() - gameStarted) > 180 or serverstorage:WaitForChild("Values"):WaitForChild("BattleValue").Value == false or #Teams["Alive"]:GetPlayers() <= 1
It checks every half a second if there’s 1 or less players, you can make it faster by changing the time in wait(). You can also pretty much delete the BattleValue unless you need it for any other scripts. Also don’t make it repeat every wait() since that could be a bit laggy, you can check every like half a second for count of players alive.
The actual reason for this error is that you are never modifying the BattleValue.Value property. Instead, you are just modifying the local variable, that you’ve named BattleValue. Here’s some fixed code:
local BattleValue = serverstorage:WaitForChild("Values"):WaitForChild("BattleValue")
BattleValue.Value = true
coroutine.wrap(function()
wait(180)
print("Game timed out")
BattleValue.Value = false
end)
repeat
wait()
local playersAlive = Teams["Alive"]:GetPlayers()
until BattleValue.Value == false or #playersAlive <= 1