0 views0 copies0 likes

Tag-Based Lighting Switch for Large Builds

Universal script

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

Utilities Verified

Script code

14 lines ยท 0.6 KB
Download
local CollectionService = game:GetService("CollectionService")local tag = "WorkshopLamp"local prompt = Instance.new("ProximityPrompt", workspace:WaitForChild("MasterLightSwitch"))prompt.ActionText = "Toggle workshop lights"local enabled = truelocal function update(instance)	if instance:IsA("Light") then instance.Enabled = enabled endendCollectionService:GetInstanceAddedSignal(tag):Connect(update)prompt.Triggered:Connect(function()	enabled = not enabled	for _, instance in CollectionService:GetTagged(tag) do update(instance) endend)for _, instance in CollectionService:GetTagged(tag) do update(instance) end

About this script

Tag individual Light instances with WorkshopLamp and add a part called MasterLightSwitch. The server toggles every tagged light and applies the current state when a new light receives the tag. This works across unrelated models, so you can move lamps without editing paths. Use Studio's tag tools to add a lamp during a playtest and confirm that it matches the switch.

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 CollectionService = game:GetService("CollectionService")
local tag = "WorkshopLamp"
local prompt = Instance.new("ProximityPrompt", workspace:WaitForChild("MasterLightSwitch"))
prompt.ActionText = "Toggle workshop lights"
local enabled = true
local function update(instance)
	if instance:IsA("Light") then instance.Enabled = enabled end
end
CollectionService:GetInstanceAddedSignal(tag):Connect(update)
prompt.Triggered:Connect(function()
	enabled = not enabled
	for _, instance in CollectionService:GetTagged(tag) do update(instance) end
end)
for _, instance in CollectionService:GetTagged(tag) do update(instance) end