Lets take a look at this piece by piece.
First line:
if script.Parent.items:GetChildren().Name == "Cube" then
To start with, make sure you are familiar with what the GetChildren() function actually does. It returns a table, not a Part! A table doesn't have a Name property, so you can't check if the Name of a table is "Cube".
Now let's look at the next bit:
if light.Parent.BrickColor == "Br. yellowish green" then
light.Color = Color3.new["Br. yellowish green"]
end
if light.Parent.BrickColor == "Neon orange" then
light.Color = Color3.new["Neon orange"]
end
if light.Parent.BrickColor == "Bright orange" then
light.Color = Color3.new["Bright orange"]
end
if light.Parent.BrickColor == "Institutional white" then
light.Color = Color3.new["Institutional white"]
end
You don't need to use if statements here! The above can be simplified to:
light.Color = light.Parent.BrickColor.Color
The next bit:
light:clone().Parent = script.Parent.items:GetChildren()
Again, GetChildren() returns a table, not a Part (or each Part one-by-one, for that matter).
I'll write a script that does a similar thing for you and explain it along the way.
First let's start by making the PointLight and setting it's properties, which you do very well so I'll just copy it:
light = Instance.new("PointLight")
light.Brightness = 2
light.Range = 6
light.Shadows = true
light.Enabled = true
The next step is very important to becoming a proficient scripter, it's called Iteration.
We are going to iterate through each element of the table returned by the GetChildren() method, this just means that we're going to go through each part one-by-one.
for _,part in pairs(script.Parent.items:GetChildren())
if part.Name == "Cube" then
newLight = light:clone()
newLight.Color = part.BrickColor.Color
newLight.Parent = part
end
end
Also, don't forget that Lua (and most other programming languages) are case-sensitive, if you don't use the right capitalisation for the names of things that you have created, there will be an error.
Make sure that, when you run the script, you have View > Output Window enabled so that you can see if any errors come up.
Here is the final script:
light = Instance.new("PointLight")
light.Brightness = 2
light.Range = 6
light.Shadows = true
light.Enabled = true
for _,part in pairs(script.Parent.items:GetChildren())
if part.Name == "Cube" then
newLight = light:clone()
newLight.Color = part.BrickColor.Color
newLight.Parent = part
end
end
I hope that helps!