How to turn all lights off from one button?

If you have a lot of lights in various folders and you don’t want to create a variable for all of them, you can use CollectionService.

for _, v in ipairs(CollectionService:GetTagged("Light")) do
    v.Enabled = not v.Enabled
end

You have to tag all of your lights with “Light” first though.

Yes. Having 2 parts with the same name will “confuse” the script. Name each part differently to avoid this issue.
There is no problem when :

  • The parent of the part you want to define has the same name of the other part’s name
    Example : Two parts named Ragdoll are parents of two parts, Part1 and Part2
  • One of the defined part is in a different folder/model/part than the other part.

There will be an issue when :

  • The part you define has the same name of any part in the same folder/model/part
  • The parts you define are named identically
    Example :
local Part = game.Workspace.Model.Part
local RandomPart = game.Workspace.Model.Part
  • You define the same part two times. In this case, the script will take the last version which you have defined it
2 Likes