I was trying to make a graphical ambient system in my game but I ran into a roadblock. The script is running through the workspace and looking for parts with the Attribute “Ambient” in them. There were a total of 4 instances that matched, however the scripts only takes one of them to operate with. I don’t know why or how it happened. I would appreciate any help!
for _, desc in pairs(workspace:GetDescendants()) do
print("test stage 1")
if desc:GetAttribute("Ambient") and desc:IsA("BasePart") or desc:IsA("SpotLight") then
print(desc.Name) -- Only printed one instance
local M1 = TweenService:Create(Lighting, TI, Dawn1)
local M2 = TweenService:Create(desc, TI, Dawn2)
local M3 = TweenService:Create(Lighting, TI, Morning1)
local M4 = TweenService:Create(desc, TI, Morning2)
local M5 = TweenService:Create(Lighting, TI, Night)
while task.wait() do
if Lighting.ClockTime >= 5 and Lighting.ClockTime < 8 then
M1:Play()
M2:Play()
print("New day!")
elseif Lighting.ClockTime >= 8 and Lighting.ClockTime < 17 then
M3:Play()
M4:Play()
print("Good Morning!")
elseif Lighting.ClockTime >= 17 and Lighting.ClockTime < 5 then
M5:Play()
print("Good night~")
end
end
end
end