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

Scripting Help: How to loop this function?

Asked by 8 years ago
--yellow on
ELights1 = Game.Workspace.[BUS MODEL].Light1.Light.Disabled = false
ELights2 = Game.Workspace.[BUS MODEL].Light2.Light.Disabled = false
ELights3 = Game.Workspace.[BUS MODEL].Light3.Light.Disabled = false
ELights4 = Game.Workspace.[BUS MODEL].Light4.Light.Disabled = false
DLights1 = Game.Workspace.[BUS MODEL].Light1.Light.Disabled = true
DLights2 = Game.Workspace.[BUS MODEL].Light2.Light.Disabled = true
DLights3 = Game.Workspace.[BUS MODEL].Light3.Light.Disabled = true
DLights4 = Game.Workspace.[BUS MODEL].Light4.Light.Disabled = true


function onClick(mouse)
ELights1
ELights2
wait(0.3)
DLights1
DLights2
ELights3
ELights4
wait(0.3)
DLights3
DLights4

end
script.Parent.MouseButton1Click:connect(onClick)

Hello! As I am fairly new to creating loops, I would like to know how to insert a loop into the function to repeat it for a set amount of time.

Ignore [BUS MODEL] as I am at school and the model is not in front of me at this moment.

1 answer

Log in to vote
0
Answered by 8 years ago

Explanation in chat.

--yellow on
ELights1 = Game.Workspace.[BUS MODEL].Light1.Light.Disabled = false
ELights2 = Game.Workspace.[BUS MODEL].Light2.Light.Disabled = false
ELights3 = Game.Workspace.[BUS MODEL].Light3.Light.Disabled = false
ELights4 = Game.Workspace.[BUS MODEL].Light4.Light.Disabled = false
DLights1 = Game.Workspace.[BUS MODEL].Light1.Light.Disabled = true
DLights2 = Game.Workspace.[BUS MODEL].Light2.Light.Disabled = true
DLights3 = Game.Workspace.[BUS MODEL].Light3.Light.Disabled = true
DLights4 = Game.Workspace.[BUS MODEL].Light4.Light.Disabled = true

debounce=false

function onClick(mouse)
if not debounce then
debounce=true
i=150 --change this to the specified time in seconds
repeat wait(0.4)
ELights1
ELights2
wait(0.3)
DLights1
DLights2
ELights3
ELights4
wait(0.3)
DLights3
DLights4
until i==0
debounce=false
end

end
script.Parent.MouseButton1Click:connect(onClick)

I added a debounce so you can't activate during activation.

If I helped, hit that accept button!

0
Thank you very much, my good friend! NikolaiGretsky 10 — 8y
Ad

Answer this question