Firstly, you're not horrible in scripting. In this website, people are here to help you, not to ridicule you. You should look in the output window. There's a lot you can see from there, that will help you in the long run.
02 | parts = script.Parent.Parent.Lights:GetChildren() |
05 | for i, v in pairs (parts) do |
07 | light = v:GetChildren() |
So, firstly, I have marked the 2 points where it should error. numero uno should still work, since you're only defining a variable, but numero dos (i take french) shouldn't. The reason why is that GetChildren will return a table of objects. So if we did something like...
1 | local parts = game.Workspace:GetChildren() |
5 | parts = { workspace.Part, workspace.Baseplate } |
So how would we fix this? Well, we could use a pairs loop to check all the children and enable it. I'm going to assume that all the children have pointlights in them, so it's safe to do this.
02 | parts = script.Parent.Parent.Lights:GetChildren() |
05 | for i, v in pairs (parts) do |
07 | light = v:GetChildren() |
08 | for _,t in pairs (light) do |
Now that we have that done, we can do the same thing to the next.
03 | for i, v in pairs (parts) do |
05 | light = v:GetChildren() |
06 | for _,w in pairs (light) do |
14 | if isOn = = true then off() else on() end |
17 | script.Parent.MouseButton 1 Down:connect(onClicked) |
There we go, both functions are rewritten. So if we wanted to put this all together then....
02 | parts = script.Parent.Parent.Lights:GetChildren() |
05 | for i, v in pairs (parts) do |
07 | light = v:GetChildren() |
08 | for _,t in pairs (light) do |
17 | for i, v in pairs (parts) do |
19 | light = v:GetChildren() |
20 | for _,w in pairs (light) do |
28 | if isOn = = true then off() else on() end |
31 | script.Parent.MouseButton 1 Down:connect(onClicked) |
I am going to assume that all parts have a light inside of them. It will still work otherwise, because pairs loops don't break on error.