Hello, I’m currently working on a time script that shows what time of day it is (this is my script below)
local clock = game.Lighting.ClockTime
while wait(.1) do
if clock > 0 and clock < 4 then
script.Parent.Text = "Midnight"
elseif clock > 4 and clock < 10 then
script.Parent.Text = "Morning"
elseif clock > 10 and clock < 12 then
script.Parent.Text = "Noon"
elseif clock > 12 and clock < 17 then
script.Parent.Text = "Afternoon"
elseif clock > 17 and clock < 20 then
script.Parent.Text = "Evening"
elseif clock > 20 and clock < 24 then
script.Parent.Text = "Night"
end
end
but it doesn’t work, it only works once and it makes the text “Morning,” but then nothing happens after that. (the time of day originally set for lighting is 5:01:00) and there are no errors…
weird.
you logged clock as ClockTime, a number value, so the variable clock will always be the initial ClockTime value.
local clock = game.Lighting
while wait(.1) do
if clock.ClockTime > 0 and clock.ClockTime < 4 then
script.Parent.Text = "Midnight"
elseif clock.ClockTime > 4 and clock.ClockTime < 10 then
script.Parent.Text = "Morning"
elseif clock.ClockTime > 10 and clock.ClockTime < 12 then
script.Parent.Text = "Noon"
elseif clock.ClockTime > 12 and clock.ClockTime < 17 then
script.Parent.Text = "Afternoon"
elseif clock.ClockTime > 17 and clock.ClockTime < 20 then
script.Parent.Text = "Evening"
elseif clock.ClockTime > 20 and clock.ClockTime < 24 then
script.Parent.Text = "Night"
end
end