So basically, I wrote a script for the day/night cycle that works perfectly, but I also have stuff like lanterns and I want to make them turn off when it’s a day, and turn on when it’s a night.
I hope anyone would help me because I don’t get any errors in the output and I don’t know whats the problem.
lighting.ClockTime.Changed:Connect(function()
if lighting.ClockTime == 17.667 then
for i, v in pairs(Lanterns:GetDescendants()) do
if v:IsA("MeshPart") then
if v.Material == Enum.Material.Neon then
v.Transparency = 0
v.BrickColor = BrickColor.Cork
end
end
end
for i, v in pairs(HouseLights:GetDescendants()) do
if v:IsA("Part") then
if v.Material == Enum.Material.Neon then
v.BrickColor = BrickColor.Cork
end
end
if v:IsA("PointLight") then
v.Enabled = true
end
end
elseif lighting.ClockTime == 7 then
for i, v in pairs(Lanterns:GetDescendants()) do
if v:IsA("MeshPart") then
if v.Material == Enum.Material.Neon then
v.Transparency = 0.5
v.BrickColor = Color3.fromRGB(0, 0, 0)
end
end
end
for i, v in pairs(HouseLights:GetDescendants()) do
if v:IsA("Part") then
if v.Material == Enum.Material.Neon then
v.BrickColor = Color3.fromRGB(0, 0, 0)
end
end
if v:IsA("PointLight") then
v.Enabled = false
end
end
end
end)
Nope. The script still doesn’t work. The time has passed, and the lanterns remain turned on.
Thats how it looks now:
lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
if lighting.ClockTime >= 17.667 and lighting.ClockTime <= 7 then
for i, v in pairs(Lanterns:GetDescendants()) do
if v:IsA("MeshPart") then
if v.Material == Enum.Material.Neon then
v.Transparency = 0
v.BrickColor = BrickColor.Cork
end
end
end
for i, v in pairs(HouseLights:GetDescendants()) do
if v:IsA("Part") then
if v.Material == Enum.Material.Neon then
v.BrickColor = BrickColor.Cork
end
end
if v:IsA("PointLight") then
v.Enabled = true
end
end
elseif lighting.ClockTime >= 7 and lighting.ClockTime <= 17.666 then
for i, v in pairs(Lanterns:GetDescendants()) do
if v:IsA("MeshPart") then
if v.Material == Enum.Material.Neon then
v.Transparency = 0.5
v.BrickColor = Color3.fromRGB(0, 0, 0)
end
end
end
for i, v in pairs(HouseLights:GetDescendants()) do
if v:IsA("Part") then
if v.Material == Enum.Material.Neon then
v.BrickColor = Color3.fromRGB(0, 0, 0)
end
end
if v:IsA("PointLight") then
v.Enabled = false
end
end
end
end)
Alright. Thank you all guys, I fixed it. After me fixing the :GetPropertyChangedSignal and the >= and <= it gave me an error about BrickColor in RGB like in this lane: