Light switch not working

and you can substitute all the names for just Parent, but then the closest parent has to be named correctly?

The reason it is Parent is because if a object1 is inside the object2, then object2 would be object1 's parent

1 Like
local LightBulb = game.Workspace.House.Garage.GarageLights.Light.LightBox
local LightSwitch = game.Workspace.House.Garage.GarageLights.LightSwitch.SwitchClickPart

LightSwitch.ClickDetector.MouseClick:connect(function()
    if LightBulb.Pointlight.Enabled = false then
       LightBulb.Pointlight.Enabled = true
   else
       Lightbulb.Pointlight.Enabled = false
    end
end)

You must rename some parts like “SwitchClickPart”,it is basically the part that ticks after being click
About the 6 parts named LightBox,select them all and Union them,after that,insert the Pointlight,and i will tell what to do later.

1 Like

Okay, so for the actual light, not the switch, and remember there is multiple lights that switch on as you click the switch, you would have a

script.

before it or no? because the script isn’t anywhere near the pointlight.

So can you provide me an example of the names of the parts? switch, and lights, etc. I don’t know what to rename and to change.

EDIT: cant believe this is taking 46 replies. I am so dumb.

If there is more then one lights then you could put the same scripts inside diffrent switchs and then change the light variable to where the lightbulb is.

?? so there would be 6 different switches on the wall for one garage light set? can you elaborate? I don’t understand…

Then there would be six diffrent scripts. Each one in different switchs

so it would look like this…
Screenshot (5) cut

each for 1 light?

he might want the switch to turn on all the lights, not have seperate switches to turn each light on/off, if he plans to.

1 Like

Yeah that’s what I want.

30char

omg…taking 51 replies…i am sooooo dumb.

"for"would probably work,i dont actually know how to use it…

Well,i’am going to developer.roblox.com to learn about it,bye.

Okay, let me rephrase.

I need 1 switch in a folder, to turn on 6 different lights, all duplicated, in the same folder as the switch. The model “LightSwitch” has the actual light frame, and screws in it with the “switch”. The “switch” is the actual button on the “LightSwitch”. The “switch” has a “Script” and a “ClickDetector”. The 6 different lights are all “LightBox” parts, with a “PointLight” and a “IndustrialLight” part which is a frame.

then you would have to write code that not only gets each light, but also gets each PointLight in it.
you can create a table like this:

local lights = {
light1 = light1,
light2 = light2,
light3 = light3,
light4 = light4,
light5 = light5,
light6 = light6
}

then add something that gets the PointLight in each one, like this:

lights.lightNum:FindFirstChild("PointLight")--lightNum, as in the number name of the table like light1 or light2

inside a for loop.
idk how to create an example of the for loop since i dont know how for loops exactly work yet(mostly with i, v, and pairs), but im sure someone know how.

1 Like

Screenshot (6) cut

I wouldn’t need that. This is waaay to simple for this. My original script (Up top) worked just fine. But once I move the objects to folders (the switch, and the lights), away from the original workspace the script stopped working.

and “this is waaay to simple” turns out to be 57 replies, im such a hypocrite.

You could just put it in workspace.

Yeah but I like orginized, even though if it is a simple model (a little house).

Well if you really want it to work then just do it lol