Okay, so I have a model with a bunch of neon parts and I mean a bunch like 300+ and I don't wanna change all their names bc it'll take forever so how could I change all the spotlights colors inside those block, it goes like this: Lights>Neon x300+> Spotlight(Inside every neon block), How can I change every single one of those spotlights color3 property with a switch at once?
local Lights = workspace.Lights:GetChildren() for _,Neon in pairs(Lights) do if (Neon:FindFirstChildOfClass("SpotLight")) then Neon.SpotLight.Color = Color3.fromRGB(255,255,255) end end
I assume your explorer looks something like this.
Insert a part into the workspace, and insert a ClickDetector inside of that part.
Create a Script inside of ServerScriptService:
local Part = game.Workspace:WaitForChild("Part") local ClickDetector = Part:WaitForChild("ClickDetector") ClickDetector.MouseClick:Connect(function() for i, v in pairs(game.Workspace.Lights:GetChildren()) do local R = math.random(255) local G = math.random(255) local B = math.random(255) v.SpotLight.Color = Color3.fromRGB(R, G, B) --Variables aren't necessary but I added them to avoid --the assignment spanning multiple lines end end)
So, whenever someone clicks on the part you created, it'll loop through the entire model that contains the parts, and on each iteration, it'll change the SpotLight inside of each part so that they are a different color.
In this example, it just randomizes the color, but you can remove the three variables and the assignment of the SpotLight's color if you want to do something else.