If you want repeated checking, you'll probably want OnUpdate. OnUpdate is a frame script that fires every time the frame is re-drawn (e.g. a lot). You usually want to throttle this, as doing operations around 60 times a second is usually redundant.
In this example, I've throttled the function to check once every two seconds.
Code:
-- Make a local variable that tells us whether the sound was played previously during this (minute == 0) occurrence
local firedLast = false
CreateFrame("Frame"):SetScript("OnUpdate",function(self,elapsed)
-- increment a member on the frame, initializing it to zero if it has no value
self.elapsed = (self.elapsed or 0)+elapsed
-- if 2 seconds passed since the last time, then check current time
if self.elapsed >= 2 then
-- make sure you call tonumber() if you compare to a number
local minutes = tonumber(date("%M"))
if minutes == 0 then
if not firedLast then
-- we didn't play it during this minute #0 yet, so do it now
PlaySoundFile("Sound\\Spells\\Flare.wav")
-- make sure it doesn't play until after minute has been ~= 0
firedLast = true
end
else
-- reset the var so that the sound will be played again the next time minute == 0
firedLast = false
end
-- reset the internal time counter to zero so it starts counting the 2 second throttle again
self.elapsed = 0
end
end)