Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What if you need to turn off all the lights, but there is a problem they are in different folders?

Asked by 1 year ago

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!

1 answer

Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

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

0
hmm... this one fits and it works thank you ZomarPereira0 2 — 1y
Ad

Answer this question