How do I repeat code for a certain amount of times?

How do I repeat this code for 17 seconds?
here:

	gui.Frame.Loading.A.BackgroundTransparency = 0
	wait(.1)
	gui.Frame.Loading.A.BackgroundTransparency = 0.8
	gui.Frame.Loading.B.BackgroundTransparency = 0
	wait(.1)
	gui.Frame.Loading.B.BackgroundTransparency = 0.8
	gui.Frame.Loading.C.BackgroundTransparency = 0
	wait(.1)
	gui.Frame.Loading.C.BackgroundTransparency = 0.8
	gui.Frame.Loading.D.BackgroundTransparency = 0
	wait(.1)
	gui.Frame.Loading.D.BackgroundTransparency = 0.8
	gui.Frame.Loading.E.BackgroundTransparency = 0
	wait(.1)
	gui.Frame.Loading.E.BackgroundTransparency = 0.8
	gui.Frame.Loading.F.BackgroundTransparency = 0
	wait(.1)
	gui.Frame.Loading.F.BackgroundTransparency = 0.8
	gui.Frame.Loading.G.BackgroundTransparency = 0
	wait(.1)
	gui.Frame.Loading.G.BackgroundTransparency = 0.8
	gui.Frame.Loading.H.BackgroundTransparency = 0


Can you show us what this does? It looks like this could be far simpler than it is currently…

Edit: Notably all the alphabet items under Loading, I’m confused as to what they are.

try this

local seconds = 17 --how many seconds
local speed = 1 --delay lower more faster


for count = 1,seconds do wait(speed)
    gui.Frame.Loading.A.BackgroundTransparency = 0
	wait(.1)
	gui.Frame.Loading.A.BackgroundTransparency = 0.8
	gui.Frame.Loading.B.BackgroundTransparency = 0
	wait(.1)
	gui.Frame.Loading.B.BackgroundTransparency = 0.8
	gui.Frame.Loading.C.BackgroundTransparency = 0
	wait(.1)
	gui.Frame.Loading.C.BackgroundTransparency = 0.8
	gui.Frame.Loading.D.BackgroundTransparency = 0
	wait(.1)
	gui.Frame.Loading.D.BackgroundTransparency = 0.8
	gui.Frame.Loading.E.BackgroundTransparency = 0
	wait(.1)
	gui.Frame.Loading.E.BackgroundTransparency = 0.8
	gui.Frame.Loading.F.BackgroundTransparency = 0
	wait(.1)
	gui.Frame.Loading.F.BackgroundTransparency = 0.8
	gui.Frame.Loading.G.BackgroundTransparency = 0
	wait(.1)
	gui.Frame.Loading.G.BackgroundTransparency = 0.8
	gui.Frame.Loading.H.BackgroundTransparency = 0
end
seconds = 17

while true do
gui.Frame.Loading.A.BackgroundTransparency = 0
wait(.1)
gui.Frame.Loading.A.BackgroundTransparency = 0.8
gui.Frame.Loading.B.BackgroundTransparency = 0
wait(.1)
gui.Frame.Loading.B.BackgroundTransparency = 0.8
gui.Frame.Loading.C.BackgroundTransparency = 0
wait(.1)
gui.Frame.Loading.C.BackgroundTransparency = 0.8
gui.Frame.Loading.D.BackgroundTransparency = 0
wait(.1)
gui.Frame.Loading.D.BackgroundTransparency = 0.8
gui.Frame.Loading.E.BackgroundTransparency = 0
wait(.1)
gui.Frame.Loading.E.BackgroundTransparency = 0.8
gui.Frame.Loading.F.BackgroundTransparency = 0
wait(.1)
gui.Frame.Loading.F.BackgroundTransparency = 0.8
gui.Frame.Loading.G.BackgroundTransparency = 0
wait(.1)
gui.Frame.Loading.G.BackgroundTransparency = 0.8
gui.Frame.Loading.H.BackgroundTransparency = 0

wait(.3) -- add .3 for full second

seconds -= 1
if seconds == 0 then break end
end


You’d benefit from learning how loops work.

https://www.lua.org/pil/4.3.html

1 Like