计时器脚本在2:29停止,不会从那里开始倒计时。它应该倒数到零,但会在一次循环后停止。while true do循环继续运行,但要么文本标签不显示它,要么分钟和秒变量没有改变。我需要帮助才能让这件事起作用。
local starterGui = game:GetService("StarterGui")
local Guis = starterGui.RoundTimer --Includes the time textlabel.
local Seconds = 30
local Minutes = 2
repeat
wait(1)
if Seconds < 9 then
if Seconds == 0 then
Seconds = 59
Minutes = Minutes - 1
else
Seconds = Seconds - 1
end
Guis.Time.Text = tostring(Minutes)..":0"..tostring(Seconds)
else
Seconds = Seconds - 1
Guis.Time.Text = tostring(Minutes)..":"..tostring(Seconds)
end
until Seconds < 1 and Minutes < 1
发布于 2021-07-21 02:43:20
我没有看到整体逻辑有任何问题,所以没有理由在2:29停止,但格式有一些问题,因为这是我在运行脚本(片段)时得到的结果:
1:10
1:9
1:8
1:07
1:06
1:05
1:04
1:03
1:02
1:01
1:00
0:059
0:58
如您所见,:8、:9和:059的格式不正确。
像这样的东西可能工作得更好一些:
repeat
Guis.Time.Text = ("%d:%02d"):format(Minutes, Seconds)
wait(1)
Seconds = Seconds - 1
if Seconds < 0 then
Minutes = Minutes - 1
Seconds = 59
end
until Seconds < 1 and Minutes < 1
https://stackoverflow.com/questions/68459699
复制相似问题