Hi all, I wanted to ask for help today, I need after pressing the button should turn off all the lights but I do not want to write a very long script, so I need help. To make it easier for me to write the script each model is called "light" in the "light" part and there are two light sources are "PointLight" and "SurfaceLight". If you can do it, I will be very grateful!
✓ ANSWER ACCEPTED
What if you need to turn off all the lights, but there is a problem they are in different folders?
1 answer
✓ Accepted answer
First, add an attribute to each light (or a tag with collectionservice)
local CS = game:GetService("CollectionService")
local tag = "" -- whatevever the name of your attribute/tag is
then do
for _, v in ipairs(workspace:GetDescendants()) do
if v:GetAttribute(tag) or CS:HasTag(v, tag) then
--do your code
end
end
This only requires 1 script in serverscriptservice
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
hmm... this one fits and it works thank you