Hello, I'm just getting started and I'm very new to coding. I'd appreciate some light on my issue here.
Thanks!
Lights = script.Parent:GetChildren() for i, v in pairs(Lights) do if game.Lighting:GetMinutesAfterMidnight() > 6 * 60 then v.Material = Enum.Material.Plastic end if game.Lighting:GetMinutesAfterMidnight() < 18 * 60 then v.Material = Enum.Material.Neon -- It breaks here. end end
You are looping through an entire group (lighting) and changing a value that does not exist in most objects (v). As your error says, "Material" wasn't found in a 'script' object since they can only be found in 'part' objects. So to solve this, you have to do some error checking to make sure 'v' is a 'part' and not a 'script' and such. To check whether 'v' is a 'part', you can simply use this one command in an if statement:
if v:IsA("Part") do
and have that if statement placed as the first line within that for loop and edit the loop as needed to close off the if statements. Hopefully this helps you and happy scripting~