Script Problems-doesn’t work

I’m working on a game, but I am running into some problems. I made this script, at first just with l1, and it worked. When I added the others, clicking the block doesn’t even set the transparency to 0 anymore, so something is wrong. Please tell me what I did, this is one of my first scripts, so it’s probably a simple mistake. Thanks!

’’’local clickDetector = script.Parent.ClickDetector

l = script.Parent.Parent.Parent.Elights.DOO.Dad.PointLight
b = script.Parent.Parent.Parent.Elights.DOO.Bulb
s = script.Parent.Parent.Parent.Elights.DOO.Dad.PointLight.Flic

l1 = script.Parent.Parent.Parent.Elights.l1.Dad.PointLight
b1 = script.Parent.Parent.Parent.Elights.l1.Bulb
s1 = script.Parent.Parent.Parent.Elights.l1.Dad.PointLight.Flic

l2 = script.Parent.Parent.Parent.Elights.l2.Dad.PointLight
b2 = script.Parent.Parent.Parent.Elights.l2.Bulb
s2 = script.Parent.Parent.Parent.Elights.l2.Dad.PointLight.Flic

l3 = script.Parent.Parent.Parent.Elights.l3.Dad.PointLight
b3 = script.Parent.Parent.Parent.Elights.l3.Bulb
s3 = script.Parent.Parent.Parent.Elights.l3.Dad.PointLight.Flic

l4 = script.Parent.Parent.Parent.Elights.l4.Dad.PointLight
b4 = script.Parent.Parent.Parent.Elights.l4.Bulb
s4 = script.Parent.Parent.Parent.Elights.l4.Dad.PointLight.Flic

l5 = script.Parent.Parent.Parent.Elights.l5.Dad.PointLight
b5 = script.Parent.Parent.Parent.Elights.l5.Bulb
s5 = script.Parent.Parent.Parent.Elights.l5.Dad.PointLight.Flic

l6 = script.Parent.Parent.Parent.Elights.l6.Dad.PointLight
b6 = script.Parent.Parent.Parent.Elights.l6.Bulb
s6 = script.Parent.Parent.Parent.Elights.l6.Dad.PointLight.Flic

l7 = script.Parent.Parent.Parent.Elights.l7.Dad.PointLight
b7 = script.Parent.Parent.Parent.Elights.l7.Bulb
s7 = script.Parent.Parent.Parent.Elights.l7.Dad.PointLight.Flic

l8 = script.Parent.Parent.Parent.Elights.l8.Dad.PointLight
b8 = script.Parent.Parent.Parent.Elights.l8.Bulb
s8 = script.Parent.Parent.Parent.Elights.l8.Dad.PointLight.Flic

l9 = script.Parent.Parent.Parent.Elights.l9.Dad.PointLight
b9 = script.Parent.Parent.Parent.Elights.l9.Bulb
s9 = script.Parent.Parent.Parent.Elights.l9.Dad.PointLight.Flic

l10 = script.Parent.Parent.Parent.Elights.l10.Dad.PointLight
b10 = script.Parent.Parent.Parent.Elights.l10.Bulb
s10 = script.Parent.Parent.Parent.Elights.l10.Dad.PointLight.Flic

l11 = script.Parent.Parent.Parent.Elights.l11.Dad.PointLight
b11 = script.Parent.Parent.Parent.Elights.l11.Bulb
s11 = script.Parent.Parent.Parent.Elights.l11.Dad.PointLight.Flic

function onMouseClick()
script.Parent.Transparency = 1
l.Range = 0
b.Material = Enum.Material.SmoothPlastic
s.Disabled = true
l1.Range = 0
b1.Material = Enum.Material.SmoothPlastic
s1.Disabled = true
l2.Range = 0
b2.Material = Enum.Material.SmoothPlastic
s2.Disabled = true
l3.Range = 0
b3.Material = Enum.Material.SmoothPlastic
s3.Disabled = true
l4.Range = 0
b4.Material = Enum.Material.SmoothPlastic
s4.Disabled = true
l5.Range = 0
b5.Material = Enum.Material.SmoothPlastic
s5.Disabled = true
l6.Range = 0
b6.Material = Enum.Material.SmoothPlastic
s6.Disabled = true
l7.Range = 0
b7.Material = Enum.Material.SmoothPlastic
s7.Disabled = true
l8.Range = 0
b8.Material = Enum.Material.SmoothPlastic
s8.Disabled = true
l9.Range = 0
b9.Material = Enum.Material.SmoothPlastic
s9.Disabled = true
l10.Range = 0
b10.Material = Enum.Material.SmoothPlastic
s10.Disabled = true
l11.Range = 0
b11.Material = Enum.Material.SmoothPlastic
s11.Disabled = true

end

clickDetector.MouseClick:connect(onMouseClick)’’’

1 Like

You can’t expect someone to answer this big of a code. You should really just ask a question about a SPECIFIC thing.

1 Like

Oh. Ok. Sorry. Thanks for telling me.

Course m8! Always happy to help! :smiley:

Specify what are you trying to achieve, and please make the code like this

--codes

use the ` for code like this
image

Here is a more specific question:

Basically, I made a script that says, when you click a button, 11 lights turn out. It worked when the script only told 1 light to turn out, but when I repeated the process for the other 10 lights, it stopped working, even the first light. When I remove the scripts for the other ten lights, the first one works again.

Ok, I made a small discovery… the problem is in the part of the code that says stuff like
l = script.Parent.Parent…etc.
When I deleted that part (all but 1), it worked again.

Are you using get descendance?

What? I am a newbie at scripting, so I don’t know what you mean. Thanks

Try to look it up and stuff. Very important part of scripting :smiley:

I got closer! It’s the part that says disable “flic” script

Learn how to use GetDesendance cause your wasting like 50 lines of code.

Found the reason! Only some of the lights had the “flic” script (made the lights flicker) but it told all the lines to disable that script!

Oh wow! Great! :smiley: Gl scripting!! :smiley: Hope I helped a lil lol!