What is the problem?
local TiempoRestante = script.Parent.Configuracion.TiempoR local ComenzarJuego = script.Parent.Configuracion.Comienzo local Mensaje = script.Parent.Configuracion.Mensaje function Comienzo() for i = 10,0 do wait(1) warn ("LOL") TiempoRestante = TiempoRestante.Value -1 Mensaje.Text = "El juego iniciara en".. i .. "segundos" if i == 0 then break end end end wait (5) Comienzo()
OUTPUT PRINT
Nothing
Línea número 6 es donde está tu problema. En un For Loop
, i
(en este ejemplo) comienza en 1 por defecto y agrega 1 por turno. Cuando i
es mayor que (o igual a) el segundo número, el circuito se detiene automáticamente.
for i = 1,10 do print(i) end
Output:
1 2 3 4... 10
cuando i
= 10, se detiene. También hay un tercer número que podrías usar: incrementos. Los incrementos determinan cuánto agregas a i
en cada turno (puede ser negativo). Ejemplo:
for i = 10,1,-1 do print(i) end
Output:
10 9 8 7... 1
Esto es lo que quieres para una cuenta atrás.
local TiempoRestante = script.Parent.Configuracion.TiempoR local ComenzarJuego = script.Parent.Configuracion.Comienzo local Mensaje = script.Parent.Configuracion.Mensaje function Comienzo() for i = 10,0,-1 do TiempoRestante = TiempoRestante.Value -1 Mensaje.Text = "El juego iniciara en".. i .. "segundos" wait(1) end end wait (5) Comienzo()
Las líneas 12 a 14 son innecesarias. El For Loop
se rompe(break) automáticamente cuando i
= 0.
¡Espero eso ayude!