|
| 26 Oct 2013 06:32 AM |
Right, so my friend wants me to make a model for him. This is basically what it does; There is one switch that controls all the lights in the model it is in (so you would have a model called LightSet1 with the Switch model and the Light model, which contains as many lights as needed). It kind of works but only one light turns on and off, presumably because they are all called the same thing and the script is getting confused. Is there any way to fix that other than naming all the lights different things, the reason being it would be a hassle to rename all the models AND the script would require editing to turn them all off? This is what I have so far:
s = script.Parent.Parent.Parent.LightModel.LightBrick.PointLight
function onClick() s.Brightness = 0 end
script.Parent.ClickDetector.MouseClick:connect(onClick)
So the script is in the Switch model, which is inside the LightSet1 model.
.: LD :. |
|
|
| Report Abuse |
|
|
|
| 26 Oct 2013 06:43 AM |
Bump. Could someone help? :c
.: LD :. |
|
|
| Report Abuse |
|
|
Quorum
|
  |
| Joined: 25 Oct 2013 |
| Total Posts: 4680 |
|
|
| 26 Oct 2013 06:47 AM |
s = script.Parent.Parent.Parent.LightModel
function onClick() for _,v in pairs(s:GetChildren()) do if v:FindFirstChild("PointLight") then v.PointLight.Brightness = 0 end end end script.Parent.ClickDetector.MouseClick:connect(onClick) |
|
|
| Report Abuse |
|
|
|
| 26 Oct 2013 06:59 AM |
Nope, that doesn't work at all...
.: LD :. |
|
|
| Report Abuse |
|
|
|
| 26 Oct 2013 07:02 AM |
Keep in mind this is what the model is like:
LightSystem1 > Lights > Light Light Light
(the Light model contains: Brick > Light > PointLight)
.: LD :. |
|
|
| Report Abuse |
|
|
Quorum
|
  |
| Joined: 25 Oct 2013 |
| Total Posts: 4680 |
|
|
| 26 Oct 2013 09:49 AM |
| Then change the 's' variable so it's directed to where all the lights are, which contain the PointLight. |
|
|
| Report Abuse |
|
|