Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I select pointlights that have a specific color?

Asked by
akito 0
6 years ago

Kinda stuck on this. Trying to use the Command Bar to select all pointlights with the color "Really blue". Anything helps.

local Lights = {}

function getLights(root)
    for i,v in pairs(root:GetChildren()) do
        if v:IsA("PointLight") and v.Color3 == ("0, 0, 255") then
            table.insert(Lights,v)
        end
        getLights(v)
    end
end

getLights(workspace)

game.Selection:Set(Lights)

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

Hello T1_Backyard! I'm here to help you.

To make this script, you can use Color3.FromRGB.

Just a mistake, don't add 3 to v.Color

local Lights = {}

function getLights(root)
    for i,v in pairs(root:GetChildren()) do
        if v:IsA("PointLight") and v.Color == Color3.fromRGB(0, 0, 255) then
            table.insert(Lights,v)
        end
        getLights(v)
    end
end

getLights(workspace)

game:GetService("Selection"):Set(Lights)

It's just that! Accepte anwser or modifie your title to add [SOLVED].

Ad

Answer this question