It only affects a single pointlight even tho the other tween works perfectly fine. Yes it prints all the pointlights.
I also tried this in a single function but didn’t help either.
--//Services
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local Lighting = game:GetService("Lighting")
--//Variables
local Parts = workspace.Game:WaitForChild("World One").Lighting:WaitForChild("Area Lights")
local All_Lights = workspace.Game["World One"]
--//Controls
local tweenInfo1 = TweenInfo.new(
5,
Enum.EasingStyle.Linear,
Enum.EasingDirection.InOut,
0,
false,
0
)
local Goal1 = {Transparency = 1}
local Goal2 = {Transparency = 0.2}
local LightGoal1 = {Range = 0}
local LightGoal2 = {Range = 60}
--//Functions
local function InitializeAreaLight(areaLight)
local lightPart = areaLight.LightingPart
local Tween1 = TweenService:Create(lightPart, tweenInfo1, Goal1)
local Tween2 = TweenService:Create(lightPart, tweenInfo1, Goal2)
Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
if Lighting:GetMinutesAfterMidnight() > 6*60 then
Tween1:Play()
lightPart.Material = Enum.Material.Plastic
end
if Lighting:GetMinutesAfterMidnight() > 18*60 then
Tween2:Play()
lightPart.Material = Enum.Material.Neon
end
end)
end
function lightAllParts(light)
if light:IsA("PointLight") then
print(light)
local lightTween1 = TweenService:Create(light, tweenInfo1, LightGoal1)
local lightTween2 = TweenService:Create(light, tweenInfo1, LightGoal2)
Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
if Lighting:GetMinutesAfterMidnight() > 6*60 then
lightTween1:Play()
end
if Lighting:GetMinutesAfterMidnight() > 18*60 then
lightTween2:Play()
end
end)
end
end
for i, areaLight in pairs(Parts:GetChildren()) do
task.spawn(function()
InitializeAreaLight(areaLight)
end)
end
for _, light in pairs(Parts:GetDescendants()) do
task.spawn(function()
lightAllParts(light)
end)
end
Parts.ChildAdded:Connect(function(areaLight)
InitializeAreaLight(areaLight)
end)