So I’ve got this script meant to switch different lights on at night, there’s a command I use to switch the game between night and day, it’s not a day/night script type of thing, but for some reason this just doesn’t work. I wrote this using the assistant thing so excuse me if I made some stupid mistake.
local RunService = game:GetService("RunService")
local Lighting = game:GetService("Lighting")
local randomColors = {
Color3.fromRGB(165, 165, 192),
Color3.fromRGB(172, 184, 254),
Color3.fromRGB(182, 172, 145),
Color3.fromRGB(255, 215, 170),
}
Lighting:GetPropertyChangedSignal("GeographicLatitude"):Connect(function()
local currentTime = Lighting:GetMinutesAfterMidnight()
local lightsFolder = Workspace:FindFirstChild("Lights")
if lightsFolder then
print("Light folder found in Workspace")
end
if not lightsFolder then
warn("Lights folder not found in Workspace")
return
end
for _, part in lightsFolder:GetDescendants() do
if Lighting.GeographicLatitude >= 30 then
if part.Name == "StreetLamp" then
local light = part:FindFirstChildOfClass("Light")
part.Material = Enum.Material.Neon
part.Color = light.Color
for _, light in part:GetChildren() do
if light:IsA("Light") then
light.Enabled = true
end
end
end
if part.Name == "Neon" then
part.Material = Enum.Material.Neon
end
if part.Name == "Lamp" then
part.Material = Enum.Material.Neon
end
if part.Name == "NeonSmooth" then
part.Material = Enum.Material.Neon
end
if part.Name == "Base" then
part.Material = Enum.Material.Neon
end
if part.Name == "Transparency" then
part.Transparency = 0
end
if part.Name == "Decal" then
for _, decal in part:GetChildren() do
if decal:IsA("Texture") then
decal.Transparency = 0
end
end
end
if part.Name == "Billboard" then
for _, billboard in part:GetChildren() do
if billboard:IsA("BillboardGui") then
billboard.Enabled = true
end
end
end
if part.Name == "Building" then
part.Material = Enum.Material.Plastic
part.Color = randomColors[math.random(1, #randomColors)]
end
local dayTexture = part:FindFirstChild("DayTexture")
local nightTexture = part:FindFirstChild("NightTexture")
if dayTexture then
dayTexture.Transparency = 1
end
if nightTexture then
nightTexture.Transparency = 0
end
for _, light in part:GetChildren() do
if light:IsA("Light") then
light.Enabled = true
end
end
for _, texture in part:GetChildren() do
if texture:IsA("Texture") and texture.Name == "EmissiveTexture" then
texture.Color3 = Color3.fromRGB(255, 255, 255)
end
end
for _, beam in part:GetChildren() do
if beam:IsA("Beam") then
beam.Enabled = true
end
end
else
if part.Name == "StreetLamp" then
part.Material = Enum.Material.Glass
part.Color = Color3.fromRGB("211,211,211")
for _, light in part:GetChildren() do
if light:IsA("Light") then
light.Enabled = false
end
end
end
if part.Name == "Neon" then
part.Material = Enum.Material.Plastic
end
if part.Name == "Lamp" then
part.Material = Enum.Material.Glass
end
if part.Name == "NeonSmooth" then
part.Material = Enum.Material.SmoothPlastic
end
if part.Name == "Base" then
part.Material = Enum.Material.Sand
end
if part.Name == "Transparency" then
part.Transparency = 1
end
if part.Name == "Decal" then
for _, decal in part:GetChildren() do
if decal:IsA("Texture") then
decal.Transparency = 1
end
end
end
if part.Name == "Billboard" then
for _, billboard in part:GetChildren() do
if billboard:IsA("BillboardGui") then
billboard.Enabled = false
end
end
end
if part.Name == "Building" then
part.Material = Enum.Material.Neon
part.Color = Color3.fromRGB(45, 45, 45)
end
local dayTexture = part:FindFirstChild("DayTexture")
local nightTexture = part:FindFirstChild("NightTexture")
if dayTexture then
dayTexture.Transparency = 0
end
if nightTexture then
nightTexture.Transparency = 1
end
for _, light in part:GetChildren() do
if light:IsA("Light") then
light.Enabled = false
end
end
for _, texture in part:GetChildren() do
if texture:IsA("Texture") and texture.Name == "EmissiveTexture" then
texture.Color3 = Color3.fromRGB(0, 0, 0)
end
end
for _, beam in part:GetChildren() do
if beam:IsA("Beam") then
beam.Enabled = false
end
end
end
end
end)```