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

Pausing and resuming loops?

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

3 comments

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.

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.

0

Bump?

1 answer

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)

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