My script throws an Workspace.Lights.Script:2: attempt to index number with 'IsA' error regardless of the changes made in it. Can somebody help me?

Hello,
I have an error with this script:

for i,v in pairs(workspace.Lights:GetDescendants()) do
    if i:IsA("PointLight") and i:IsA("Part")and i:Name("Light") and i:IsA("Model") then
        
        for _,b in pairs(workspace.Lights.Light.Light.PointLight) do
            local color = workspace.Lights.Values.Color.Value
            local Brightness = workspace.Lights.Values.Brightness.Value
            local range = workspace.Lights.Values.Range.Value
            workspace.Lights.Light.Light.PointLight.Color = color    
            workspace.Lights.Light.Light.PointLight.Brightness = Brightness
            workspace.Lights.Light.Light.PointLight.Range = range
        end
        end    
    end

But the console says this no matter what i delete or change: Workspace.Lights.Script:2: attempt to index number with β€˜IsA’. Can somebody help me please?

1 Like

i is the index, you should use v instead(value).

I is a number v is the instance. Try v:IsA instead of i:IsA

Thank you, it works successfully

2 Likes