Basically what’s supposed to happen is when the games TimeOfDay reaches a certain point the Street Lights are supposed to turn on/off. Ex TimeOfDay = 18 then lights on. TimeOfDay = 06 then Lights off.
However at the moment its just errors out when it hits the on state. Throws error “Lights is not a valid member of MeshPart” Not exactly sure why its looking at the Class Name rather than the given name.
Ok, so, with your first for loop(and it appears all your other loops), you are getting the children of the Street Lights model. And when you say v.Light, this is trying to look for a part that is a descendant of the Street Lights model. ‘v’ in this case, is referring to the children in the model. It is not referring to the classname, it just cant find a part in the Street Lights model that has a child named Light. You could do if v.Name == "Light" then and then v would equal “Light”.
Also, I’m not sure if you mean to iterate through every model named Street Light, but with how you set it up, it is only going to go through one model.
The for loop in your getThing() function iterates through all children in the street light, starting with the frame. It’s looking for a SpotLight object inside Frame.
local lighting = game.Lighting
local newTime = game.Lighting.ClockTime;
function getThing()
for i,v in pairs(game.Workspace.StreetLights[“Street Lights”]:GetChildren()) do
v.Lights.SpotLight.Brightness = 1
v.Lights.SpotLight.Brightness = 0
v.Lights.SpotLight.Brightness = 1
v.Lights.SpotLight.Brightness = 2
end
for i,v2 in pairs(game.Workspace.StreetLights["Street Lights_Small"]:GetChildren()) do
v2.Light.PointLight.Brightness = .5
v2.Light.PointLight.Brightness = 0
v2.Light.PointLight.Brightness = .5
v2.Light.PointLight.Brightness = 1
end
for i,v3 in pairs(workspace.StreetLights:GetChildren()) do
if v3:FindFirstChild'Neon' then
for _,v4 in pairs(v3.Neon:GetChildren()) do
v4.Material = "Neon"
end
end
end
end
function thing2()
for i,v in pairs(game.Workspace.StreetLights["Street Lights"]:GetChildren()) do
v.Lights.SpotLight.Brightness = 0
end
for i,v2 in pairs(game.Workspace.StreetLights["Street Lights_Small"]:GetChildren()) do
v2.Light.PointLight.Brightness = 0
end
for i,v3 in pairs(workspace.StreetLights:GetChildren()) do
if v3:FindFirstChild'SmoothPlastic' then
for _,v4 in pairs(v3.Neon:GetChildren()) do
v4.Material = "SmoothPlastic"
end
end
end
end
while wait(1) do
local Time= lighting:GetMinutesAfterMidnight();
lighting:SetMinutesAfterMidnight( Time + 1)
local NewTime = game.Lighting.TimeOfDay
if Time == 6*60 then
thing2()
elseif Time == 18*60 then
getThing()
end
game.ReplicatedStorage.Events.MainClientUpdater:FireAllClients("Time", NewTime)
end
Please can use preformatted text (Ctrl + Shift + C)
Yeah I’m wanting it to look through every model named “Street Light” so I don’t have a line for every light I want on. What your suggesting I do is something this?
for i,v in pairs(game.Workspace.StreetLights:GetChildren()) do
if v.Name == "Street Lights then
Blah
If you want it to go through everything, then yes, you would have to go about it by doing it that way. Except my answer changes a little from my original. Instead of doing if v.Name == "Light" then, you would do v.Lights.SpotLight.Brightness = 1 after checking if v.Name == “Street Lights”.