Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why wont this disable the point light?


for _, child in pairs(workspace.Carlights:GetChildren()) do
    
    if child.Name == "PointLight" then
       
        child.Enabled = false
    end
end

I get no errors, I want it to disable the pointlight in every part named "CarLights"

2 comments

0

In every part named CarLights? Or in the "Carlights" part, and every part named "PointLight" you want to disable. That's what your code suggests. Check if child.Name == "CarLights", then index that child's PointLight and disable it.

0

I dont understand

1 answer

Try using ClassName. Fix: (i think)

for _, child in pairs(workspace.Carlights:GetChildren()) do
    if child.ClassName == "PointLight" then
        child.Enabled = false
    end
end

2 comments

0

You can simple use if child:IsA("PointLight") then

0

It still doesnt work

This discussion is preserved as it was. New answers, comments, and votes are closed.