Issue: Time of day triggers a sound

Simple as can be, when the time of day strikes either 18:00 (6pm) or 6:00 (6am) a sound will be triggered to play; in this case a clock chime.

– side note, Im still new to coding so im not sure if a while true is the best option but it works for lights etc. –

Code:

local chime = script.Parent.Chimes

while true do
wait(0.1)
if game.Lighting:GetMinutesAfterMidnight() > 6.5 * 60 then
chime :Play()
wait(24)
chime :Stop()
end
if game.Lighting:GetMinutesAfterMidnight() > 17.5 * 60 then
chime :Play()
wait(24)
chime :Stop()
end
end

There shouldn’t be a space in “chime :Play()”

Use the Lightning:GetPropertyChangedSignal(‘ClockTime’) event instead of the while loop

where would I put | Lightning:GetPropertyChangedSignal(‘ClockTime’) | ? Replace the while true do, or the if “game.Lighting: etc etc”?

Use the :Connect() function since its an event.

Yeah replace the while true do

2 Likes