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
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.
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âŚ
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.
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âŚ
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.
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