Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how can i fix my intermission countdown its stuck?

Asked by 4 years ago

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

1
CODE BLOCK ACHRONlX 255 — 4y
1
please use a code block, so we can read the code properly Dec_ade 47 — 4y

4 answers

Log in to vote
0
Answered by
ACHRONlX 255 Moderation Voter
4 years ago

Put the Status.Value = "Intermission 15" and local Intertime = 15 outside of the forloop and you should be good.

0
I mean the while - do loop, my bad. ACHRONlX 255 — 4y
0
That has nothing to do with the problem. That'll change nothing. DevingDev 346 — 4y
0
I recommend using a for loop instead of a while loop for timers. Dovydas1118 1495 — 4y
Ad
Log in to vote
0
Answered by
Dec_ade 47
4 years ago
Edited 4 years ago
while true do
wait(1)
Status.Value = "Intermission" ..interTime
    if interTime ~= 0 then
        interTime = interTime - 1
   end
else 
      break;
end
Log in to vote
0
Answered by
DevingDev 346 Moderation Voter
4 years ago
local MapsFolder = game.ReplicatedStorage:WaitForChild("Maps") 
local Status = game.ReplicatedStorage:WaitForChild("Status")

local intermissionTime = 15
local startTime

while true do
    startTime = tick()
    Status.Value = "Intermission 15"
    repeat      
        local timeSinceStart = math.floor(tick() - startTime)
        Status.Value = "Intermission " .. intermissionTime - timeSinceStart

        wait(1)
    until intermissionTime - timeSinceStart <= 0

    wait(2)
end
Log in to vote
0
Answered by 4 years ago

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.

local status = game:GetService("ReplicatedStorage"):WaitForChild("Status")
local Timer = 15
for i = Timer, 1, -1 do --This just countdowns down by 1 second
    print(i)
    Status.Value = "Intermission: "..i.." seconds left"
    wait(1)
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.)

Answer this question