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

Pausing and resuming loops?

Asked by 7 years ago

Trying different options now for a while and I just can't find a way, so i'm going to ask here. I'm trying to create a button that when it's pressed (on a gui) lights flash every one second, for a plane. So when your sitting in a cockpit you press the lights button and on the wings lights start flashing. I'm a beginner scripter but this is what I've tried for the button, on a brick:


function onClicked() script.Parent.Parent.Light.Script.Disabled = true script.Parent.ClickDetector.MouseClick:connect(onClicked) end

and this is the loop on the light brick:


while true do script.Parent.PointLight.Enabled = true wait(1) script.Parent.PointLight.Enabled = false wait(1) end

Any help would be appreciated Thanks Light

1
I would really highly suggest that you go back and keep learning because your scoping is bad and it means you don't understand what your code does. User#6546 35 — 7y
0
Thanks, but this is how im trying to learn, by asking questions and just leaving comments like that does not benefit you, nor me. 0mrlight0 40 — 7y
0
Bump? 0mrlight0 40 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

You can't call a function from inside of itself. That's your only problem.

function onClicked()
    script.Parent.Parent.Light.Script.Disabled = true
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

Ad

Answer this question