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

I need help with a light script. Please help?

So, Here's a photo of my workspace, well, of which part is involved in the code:

http://prntscr.com/3o2ppq

The script I have tried has failed many times as I don't know anything about If Statements or click bricks.

Please help me with this as it important for a group meeting area that this is done.

2 comments

1

What exactly are you trying to do? I can help, just provide that.

0

I need a script which will toggle the light on and off

2 answers

while true do
wait()
p=script.Parent
if p.L1.P1.Enabled==true then
p.L1.P1.Enabled=false
p.L2.P2.Enabled=false
p.L3.P3.Enabled=false
p.L4.P4.Enabled=false
elseif p.L1.P1.Enabled==false then
p.L1.P1.Enabled=true 
p.L2.P2.Enabled=true 
p.L3.P3.Enabled=true 
p.L4.P4.Enabled=true 
end
wait(5)
end

I'm not sure all that you want, but this basically will turn them on/off then wait 5 seconds, turn them back on, wait 5, in an infinite loop

1 comment

0

Thanks for the help, but I was more looking for a button that would toggle them on and off.

So you want them to click the button and toggle lights on/off? I can help. (I don't know why people are taking rep from you over lack-of-knowledge...) First off, insert a click detector into the button. Now, insert this script into the button. (Not a LocalScript)

local on = false
local sp = script.Parent

script.Parent.ClickDetector.MouseClick:connect(function()
	if on == false then
		sp.L1.P1.Enabled = true
		sp.L2.P2.Enabled = true
		sp.L3.P3.Enabled = true
		sp.L4.P4.Enabled = true
		on = true
	elseif on == true then
		sp.L1.P1.Enabled = false
		sp.L2.P2.Enabled = false
		sp.L3.P3.Enabled = false
		sp.L4.P4.Enabled = false
		on = false
	end
end)

1 comment

0

Thank you so much. This will help a bunch!

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