Can someone fix this code, it’s not working.
local function createSkybox(moonTextureId, sunTextureId, bk, dn, ft, lf, rt, up)
local sky = Instance.new("Sky")
sky.MoonTextureId = moonTextureId
sky.SunTextureId = sunTextureId
sky.SkyboxBk = bk
sky.SkyboxDn = dn
sky.SkyboxFt = ft
sky.SkyboxLf = lf
sky.SkyboxRt = rt
sky.SkyboxUp = up
return sky
end
local morningSky = createSkybox(
"rbxassetid://4547507884",
"rbxassetid://6196665106",
"rbxassetid://6444884337",
"rbxassetid://6444884785",
"rbxassetid://6444884337",
"rbxassetid://6444884337",
"rbxassetid://6444884337",
"rbxassetid://6412503613"
)
local eveningSky = createSkybox(
"rbxassetid://4547507884",
"rbxassetid://6196665106",
"rbxassetid://16136021536",
"rbxassetid://16136025360",
"rbxassetid://16136021536",
"rbxassetid://16136021536",
"rbxassetid://16136021536",
"rbxassetid://16136023362"
)
local nightSky = createSkybox(
"rbxassetid://4547507884",
"rbxassetid://6196665106",
"rbxassetid://15536110634",
"rbxassetid://15536112543",
"rbxassetid://15536116141",
"rbxassetid://15536114370",
"rbxassetid://15536118762",
"rbxassetid://15536117282"
)
local Lighting = game:GetService("Lighting")
local function updateSky()
local currentTime = Lighting.TimeOfDay
local hour = tonumber(string.sub(currentTime, 1, 2))
if hour >= 6 and hour < 12 then
-- Morning
Lighting.Sky = morningSky
Lighting.Brightness = 2
Lighting.Ambient = Color3.fromRGB(255, 255, 255)
Lighting.OutdoorAmbient = Color3.fromRGB(200, 200, 200)
elseif hour >= 18 and hour < 20 then
Lighting.Sky = eveningSky
Lighting.Brightness = 1.5
Lighting.Ambient = Color3.fromRGB(255, 150, 100)
Lighting.OutdoorAmbient = Color3.fromRGB(179, 119, 60)
else
Lighting.Sky = nightSky
Lighting.Brightness = 0.5
Lighting.Ambient = Color3.fromRGB(6, 6, 13)
Lighting.OutdoorAmbient = Color3.fromRGB(12, 12, 24)
end
end
updateSky()
while true do
updateSky()
wait(60)
end
The script is in ServerScriptService and all the skies are in ServerStorage in a folder named “Sky”