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

Brick color not changing when ClockTime changes?

I have it where the time changes from 3 to 8 after a certain amount of time. I want to make it where the windows will change to the yellow color during the night and turn black during the day. But, it just changes yellow entirely and stays yellow. I'm trying to use the GetMinutesAfterMidnight and a if true statement, it doesn't say anything is wrong. I'm not sure how this entirely works though, what numbers do I put? I just put 5 for now, but how many minutes after midnight should I put for it to work?


-- Variables
local Light = game.Lighting
local brick = script.Parent

-- Script
if Light:GetMinutesAfterMidnight(5) then
	brick.Color = Color3.new(100,100,0)
else
	brick.Color = Color3.new(0,0,0)
end

Is there a better way to write this?

1 answer

You should put the script in a loop or what I recommend check if the time is 5 when the lighting changes.

-- Variables
local Light = game.Lighting
local brick = script.Parent

-- Script

Light.Changed:Connect(function()
	if Light:GetMinutesAfterMidnight(5) then
		brick.Color = Color3.new(100,100,0)
	else
		brick.Color = Color3.new(0,0,0)
	end
end)

3 comments

0

Thanks, I put it in a while true do, and put (3 * 12) after, and it works!

0

Wait, it still uh is yellow after it becomes day again the second time

0

just try using elseif Lighting:GetMinutesAfterMidnight([Whatever you want])

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