I tried this but it didn't work. How would I go through every model and part to find all the Pointlights and SpotLights and disable them? I know it's possible and I can't just group the Pointlights and use that model because they are all in various models throughout the game and would be VERY VERY time consuming to find them all. If you could help It would be much appreciated.
How would I enhance this?
for i, v in pairs(game.Workspace:GetChildren())do if v:FindFirstChild("PointLight") then v.PointLight.Enabled = false end end
We can use, I believe what is called, a recursive function, or a function that will call itself. Let's start out with this:
function Search(place) end Search(game.Workspace)
Now that we have those basics, we are going to use a
for
statement to help us out.
function Search(place) for _,part in pairs(place:GetChildren()) do end end Search(game.Workspace)
Now we will need an
if
statement to check if it's a point light. I'm going to finish up the code here, as it seems you know how to do an if statement
function Search(place) for _,part in pairs(place:GetChildren()) do if part:IsA("PointLight") then part.Enabled = false else -- But what if it isn't a point light? Give up? Naw. Search(part) end end end Search(game.Workspace)