i was making a countdown for my intermission and its stuck at 14
local MapsFolder = game.ReplicatedStorage:WaitForChild("Maps") local Status = game.ReplicatedStorage:WaitForChild("Status")
while true do Status.Value = "Intermission 15" local interTime = 15 repeat wait() wait(1) interTime = interTime - 1 Status.Value = "Intermission "..interTime until interTime <= 0 wait (2) end
Put the Status.Value = "Intermission 15"
and local Intertime = 15
outside of the forloop and you should be good.
1 | while true do |
2 | wait( 1 ) |
3 | Status.Value = "Intermission" ..interTime |
4 | if interTime ~ = 0 then |
5 | interTime = interTime - 1 |
6 | end |
7 | else |
8 | break ; |
9 | end |
01 | local MapsFolder = game.ReplicatedStorage:WaitForChild( "Maps" ) |
02 | local Status = game.ReplicatedStorage:WaitForChild( "Status" ) |
03 |
04 | local intermissionTime = 15 |
05 | local startTime |
06 |
07 | while true do |
08 | startTime = tick() |
09 | Status.Value = "Intermission 15" |
10 | repeat |
11 | local timeSinceStart = math.floor(tick() - startTime) |
12 | Status.Value = "Intermission " .. intermissionTime - timeSinceStart |
13 |
14 | wait( 1 ) |
15 | until intermissionTime - timeSinceStart < = 0 |
16 |
17 | wait( 2 ) |
18 | end |
for timers/countdowns, I do not recommend using a while loop. Use a for loop instead. I'm assuming your status is a string value.
1 | local status = game:GetService( "ReplicatedStorage" ):WaitForChild( "Status" ) |
2 | local Timer = 15 |
3 | for i = Timer, 1 , - 1 do --This just countdowns down by 1 second |
4 | print (i) |
5 | Status.Value = "Intermission: " ..i.. " seconds left" |
6 | wait( 1 ) |
7 | end |
If you want it to keep going on forever, then put a while wait() do
at the top. (You can use a while true do, however, it may crash your script or studio.)