How i make two lights on when i press a button? i have this script
function LightSwitchwork() local state = script.Parent.Parent.Parent.LightState local switch = script.Parent local lamp = state.Parent.Light.Lamp local light = state.Parent.Light.Lamp.SurfaceLight local bulb1 = lamp.Parent.Bulbs.bulb1 local bulb2 = lamp.Parent.Bulbs.bulb2 if state.Value == false then state.Value = true lamp.BrickColor = BrickColor.new("Pastel yellow") lamp.Transparency = 0.8 light.Enabled = true switch.CFrame = switch.CFrame*CFrame.fromEulerAnglesXYZ(0,0,0.4) else state.Value = false lamp.BrickColor = BrickColor.new("Medium stone grey") lamp.Transparency = 0.2 light.Enabled = false end end script.Parent.ClickDetector.MouseClick:connect(LightSwitchwork)
but only works with one of the lights, Someone can help? Thanks.
The issue is that you don't actually have two lights, so how do you expect to turn two of them on?
Try creating a new light instance then copy the code for switching the first light on and edit to the turn the second light on. Remember to make the lights' names different so the code an differentiate between the two.
Although it really looks like a free-modeled script, i will assume good faith and answer anyway.
All you need to do is affect both of the bulbs in the script, like with the one already scripted on.
function LightSwitchwork() local state = script.Parent.Parent.Parent.LightState local switch = script.Parent local lamp = state.Parent.Light.Lamp local light = state.Parent.Light.Lamp.SurfaceLight local bulb1 = lamp.Parent.Bulbs.bulb1 local bulb2 = lamp.Parent.Bulbs.bulb2 if state.Value == false then state.Value = true lamp.BrickColor = BrickColor.new("Pastel yellow") lamp.Transparency = 0.8 light.Enabled = true bulb1.BrickColor = BrickColor.new("Pastel yellow") bulb1.Transparency = 0.5 --Here we invoke the bulb itself bulb1.SurfaceLight.Enabled = true --Here we invoke the SurfaceLight in the bulb bulb2.BrickColor = BrickColor.new("Pastel yellow") bulb2.Transparency = 0.5 bulb2.SurfaceLight.Enabled = true switch.CFrame = switch.CFrame*CFrame.fromEulerAnglesXYZ(0,0,0.4) else state.Value = false lamp.BrickColor = BrickColor.new("Medium stone grey") lamp.Transparency = 0.2 light.Enabled = false bulb1.BrickColor = BrickColor.new("Medium stone grey") bulb1.Transparency = 0.2 bulb1.SurfaceLight.Enabled = false bulb2.BrickColor = BrickColor.new("Medium stone grey") bulb2.Transparency = 0.2 bulb2.SurfaceLight.Enabled = false end end script.Parent.ClickDetector.MouseClick:connect(LightSwitchwork)