Hi,
I have a problem with my Streetlight-day/night cycle script.
I want to turn on multiple streetlights at once when evening/18:00:00 hits. The script works just fine with one streetlights but with 2 or more not.
see script below or link to screenshot
The problem is that the for loop checks the location, sees a PointLight, returns, and do it again and again. But the script completely skips the other streetlights because it already found the PointLight in the first streetlight that was needed (correct me if im wrong).
This is the code were Im struggling with:
local lightName = "TL" --Name of parts to store TL in
local spotLightName = "SpotLight" --Name of point TL or other TL object with .Enabled property
local model = game.Workspace.Lights.StreetLights.StreetLight.Light
while wait() do
if game.Lighting.TimeOfDay >= "18:00:00" then
for i, TL in pairs(model:GetChildren()) do --Interate through every object parented to the model
if TL.Name==lightName then --It is a TL and not just another part
TL.Material = Enum.Material.Neon
TL.Transparency = 0
TL[spotLightName].Enabled = true --Disable TL
end
end
elseif game.Lighting.TimeOfDay >= "06:00:00" then
for i, TL in pairs(model:GetChildren()) do --Interate through every object parented to the model
if TL.Name==lightName then --It is a TL and not just another part
TL.Material = Enum.Material.Glass
TL.Transparency = 0.25
TL[spotLightName].Enabled = false --Enable TL
end
end
end
wait()
end
I hope someone can help me.
If you can help me please keep it easy im a beginner.
Sorry if my grammar is terrible. (main language is Dutch)
