Basically, I want a sound to play every hour, however, it keeps looping (it is played when it ends, due to a debounce preventing it spam playing) I use ClockTime in the Lighting space to detect whenever it is dead on an hour, but it doesn't seem to read ClockTime correctly. The code is as follows:
Lighting = game.Lighting
Time = Lighting.ClockTime
Bell = script.Parent.NewtonBells
IsPlaying = false
while true do
wait()
if Time == 1 or Time == 2 or Time == 3 or Time == 4 or Time == 5 or Time == 6 or Time == 7 or Time == 8 or Time == 9 or Time == 10 or Time == 11 or Time == 12 or Time == 13 or Time == 14 or Time == 15 or Time == 16 or Time == 17 or Time == 18 or Time == 19 or Time == 20 or Time == 21 or Time == 22 or Time == 23 or Time == 24 then
if IsPlaying == true then
else
Bell:Play()
IsPlaying = true
wait(50)
print("BellFinished")
Bell:Stop()
IsPlaying = false
end
end
end

15 comments
Stop spamming the link in the text chat
I haven't spammed anything but ok
what's this abomination
its an abomination because people are refusing to help...
u don't need to do a whole lot of ors just do if Time == Time + 1 then
actually no, just make a variable for both the previous value and the new value so local previousvalue = 0 then while true do thing then make sure the new value is = to the new value then check if the new value is equal to the previous value + 1 and then set the previous value to the new value
no.
yes. if he is trying to play something every hour
my problem is that its not actually detecting the ClockTime as the correct value, its constantly thinking the clocktime is everytime, meaning the script repeatedly loops. I get that checking if it was +1 of the previous value, but if the current code doesn't read ClockTime correctly, that won't be of much help
New Code: Lighting = game.Lighting Time = Lighting.ClockTime Bell = script.Parent.NewtonBells IsPlaying = false while true do L = game.Lighting.ClockTime wait() if L == 12 or L == 24 then if IsPlaying == false then Bell:Play() print("Bells Ringing") IsPlaying = true wait(50) IsPlaying = false else --Bell Doesn't Ring print("Bell didn't ring ,isRinging") end else p
(This new code doesn't seem to detect the time correctly, it doesn't ring at all, and I don't know why)
lmao I posted a working code for your problem but I realized that I'm a bad person so I deleted it
it wasn't remotely working, but yes you are a bad person, so no one cares anyway
Instead of all the "or"s try something like if if Time >= 2 and <= 10 then
nope, that wouldn't work.