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

Error in scripting folders or others?

Asked by 5 years ago

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

0
"Configuracion" is an folder proPVPgamers_YT 40 — 5y
0
Supongo que hablas español, así que respondí en español. EzraNehemiah_TF2 3552 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

El problema

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.


La Solución:

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!

0
Por cierto, tomo clases de español en la escuela. En realidad soy de Corea. EzraNehemiah_TF2 3552 — 5y
0
Gracias!!!! Y si... Hablo español :) proPVPgamers_YT 40 — 5y
0
De nada EzraNehemiah_TF2 3552 — 5y
Ad

Answer this question