Make a weather and time script that is based on California time

I’ve been trying to make it, but It always faces issues such as; staying stuck at nighttime (i change the timezone to a different time zone when testing since its currently nighttime in the timezone), weather not changing and staying sunny. Please help :sob:

this might work:

local Lighting = game:GetService("Lighting")

-- Function to update the in-game time and weather based on California time
local function updateWeatherAndTime()
	local californiaTimeZone = -8 -- California time zone (GMT-8)
	local currentTime = os.time() -- Get current system time
	local californiaTime = currentTime + (californiaTimeZone * 3600) -- Convert to California time

	local hour = os.date("!*t", californiaTime).hour -- Extract hour from the California time

	-- Update in-game time
	game.Lighting.TimeOfDay = hour % 24 -- Set in-game time based on the hour (in 24-hour format)

	-- Update weather based on time of day (this is a simple example, you can adjust it as needed)
	if hour >= 6 and hour < 18 then
		Lighting.FogEnd = 100 -- Daytime fog settings
		Lighting.OutdoorAmbient = Color3.fromRGB(200, 200, 200) -- Daytime ambient light
	else
		Lighting.FogEnd = 30 -- Nighttime fog settings
		Lighting.OutdoorAmbient = Color3.fromRGB(50, 50, 50) -- Nighttime ambient light
	end
end

-- Run the function initially and then update every minute
updateWeatherAndTime()
while true do
	wait(60) -- Wait for 60 seconds
	updateWeatherAndTime() -- Update time and weather
end
1 Like

didn’t work, i tried local script and script in ServerScriptService

It works fine when I tried it, how is it not working?

1 Like

you can get the time in UTC from roblox then you can convert that to californias time zone, for the weather you can use httpservice to get the weather data using some public api then you can hook that up to a weather module of yours

1 Like

I tried it again, it works perfect now, I don’t know why it wasn’t working.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.