Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Error in scripting folders or others?

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

2 comments

0

"Configuracion" is an folder

0

Supongo que hablas español, así que respondí en español.

1 answer

✓ Accepted answer

#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!

3 comments

0

Por cierto, tomo clases de español en la escuela. En realidad soy de Corea.

0

Gracias!!!! Y si... Hablo español :)

0

De nada

This discussion is preserved as it was. New answers, comments, and votes are closed.