Hi, I'm trying to find out how to do this, I've tried many ways but they all throw an error, here is what I tried to use.
LobbyCount = game.Workspace:GetChildren() for i, v in pairs(LobbyCount) do Part = LobbyCount[i]:GetChildren() if Part:FindFirstChild("PointLight") then Part.PointLight.Enabled = false end end
:GetChildren()
returns a table. That's not what you want. You want to call :FindFirstChild() on the Part itself. Also, LobbyCount[i] == v.
So:
LobbyCount = game.Workspace:GetChildren() for _, Part in pairs(LobbyCount) -- If you use logical variable names, this code gets easier to read and debug if Part:FindFirstChild("PointLight") then Part.PointLight.Enabled = true end end
Here ya go
local items = {} function Scan(item) for i, v in pairs(item:GetChildren()) do print(v.Name) table.insert(items, v) if #v:GetChildren() > 0 then --Check if it has more children if so then Scan() again Scan(v) end end end Scan(game.Workspace) --This will scan everything inside Workspace for i, v in pairs(items) do --Get every object in the `items` table then set the pointlight to true if v.Name == "PointLight" then v.Enabled = true end end