Hello, @F0xBirdman Unfortunately, you might have to put the sound in a part
Try putting the sound in the part and try again.
Hello, @F0xBirdman Unfortunately, you might have to put the sound in a part
Try putting the sound in the part and try again.
Your sound isnât playing because the if condition isnât passing. Itâs good to debug your own code, such as using prints, to check why something might be occurring. For example, before your if statement, you can check if the operands youâre using are actually equal to each other:
print(game:GetService("Lighting"):GetMinutesAfterMidnight() == (3*60))
And/or just check the value at all:
print(game:GetService("Lighting"):GetMinutesAfterMidnight())
Thereâs a chance that you arenât getting an exact value where minutes after midnight is not 180. In that case you can look at other options, from making your day cycle script more predictable with the values its setting to changing when the sound should be played. A lazy example is to use ClockTime instead with a property changed signal, disconnect the connection if the condition is met (ClockTime is above or below a certain value) and then play the sound.
I know the value is correct, I have another script which turns on a light if the clocktime is 3. I think that I am not using the right terms to get a sound to play. (keep in mind that I have the sound in workspace, even in soundservice it wonât play by the script.)
It doesnât hurt to debug. A lot of developers say âI knowâ but itâs that assumption that leads to an oversight in a problem where what you think you know actually isnât correct.
Server scripts canât play sounds in SoundService, only LocalScripts can. That could also be another thing you may want to look into - instead of the server playing the sound, have the client do it. The server has no concept of sound; when it plays a sound, itâs just replicating playback to clients.
did you click âactivateâ on the sound thingy?
I had the same issue and I was able to fix it by adding a task.wait()
what i did for this problem is playing the sound through the command line
for me it was:
game:GetService(âServerScriptServiceâ).VHS.Static.Sound:Play()
so try that then start the game, worked for me.
try to use that inside LocalScript.
game.Lighting:GetPropertyChangedSignal('TimeOfDay'):Connect(function()
if game.Lighting:GetMinutesAfterMidnight() == 3 * 60 then
game:GetService("SoundService"):PlayLocalSound(SoundHere)
end
end)