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

I need help with a light script. Please help?

Asked by 10 years ago

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.

1
What exactly are you trying to do? I can help, just provide that. systematicaddict 295 — 10y
0
I need a script which will toggle the light on and off BritishActuaI 44 — 10y

2 answers

Log in to vote
1
Answered by 10 years ago
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

0
Thanks for the help, but I was more looking for a button that would toggle them on and off. BritishActuaI 44 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

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)
0
Thank you so much. This will help a bunch! BritishActuaI 44 — 10y

Answer this question