Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Day/night checking script doesn't do what its suppose to, when its day/night? (Answered)

So, I have a script that's suppose to enable other scripts when its day or night. It won't work, I have a script that changes the time every .1 seconds, so I know that's not the problem. Am I not suppose to check the Clock Time, or am I suppose to use a normal script? Then, I have 2 other scripts that enable the scripts that actually do something, when the event fires. But, it's still not working anyway.

This is my code, in a local script.

while true do
	local Event = game.ReplicatedStorage.Events
	wait()
	if game.Lighting.ClockTime >= 6.6 then
		if game.Lighting.ClockTime < 17.7 then
		Event.dayenable:FireServer()
		end
	end
	if game.Lighting.ClockTime <= 6.6 then
		if game.Lighting.ClockTime > 17.7 then
		Event.spawn2:FireServer()
		end
	end
end

Second script, thats a normal one

local ReplicatedStorage = game:GetService("ReplicatedStorage")
 
local remoteEvent = ReplicatedStorage.Events:WaitForChild("dayenable")
 
local function Enable()
script.Parent.Day.Disabled = false
end

remoteEvent.OnServerEvent:Connect(Enable)

3 comments

0

Is there a reason why you need the ClockTime check in a localscript. The game clock is synced for all players.

0

I don't know how to access it.

0

I know to change it, I have to use minutes after midnight. But I don't know how to check it in a local script.

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.