Surface Switch for a Bank of Lights thumbnail
0 views0 copies0 likes

Surface Switch for a Bank of Lights

Universal script

Copy it, then test it in your own Studio place.

Utilities Verified

Script code

13 lines · 0.5 KB
Download
local bank = workspace:WaitForChild("DisplayLights")local button = workspace:WaitForChild("LightSwitch")local prompt = Instance.new("ProximityPrompt", button)local enabled = truelocal function update()	for _, light in bank:GetDescendants() do		if light:IsA("Light") then light.Enabled = enabled end	end	button.Color = enabled and Color3.fromRGB(73, 230, 165) or Color3.fromRGB(240, 111, 76)	prompt.ActionText = enabled and "Turn off" or "Turn on"endprompt.Triggered:Connect(function() enabled = not enabled; update() end)update()

About this script

Put lights under Workspace.DisplayLights and add a part named LightSwitch. The script creates a prompt that toggles every light in the folder and updates the switch color to show its state. Each interaction changes the whole bank so individual lamps stay consistent. Try adding PointLights and SurfaceLights, then check whether the switch remains visible when the room goes dark.

Comments

Share what works, ask questions, or report an issue.

0

Log in to leave a comment.

No comments yet

Be the first to share your thoughts!

Raw Luau source

local bank = workspace:WaitForChild("DisplayLights")
local button = workspace:WaitForChild("LightSwitch")
local prompt = Instance.new("ProximityPrompt", button)
local enabled = true
local function update()
	for _, light in bank:GetDescendants() do
		if light:IsA("Light") then light.Enabled = enabled end
	end
	button.Color = enabled and Color3.fromRGB(73, 230, 165) or Color3.fromRGB(240, 111, 76)
	prompt.ActionText = enabled and "Turn off" or "Turn on"
end
prompt.Triggered:Connect(function() enabled = not enabled; update() end)
update()