Sound won't play

I am trying to play a certain sound depending on the clock time. I am getting no errors but no sound is playing. Here are the scripts:

while true do 
	if game.Lighting:GetMinutesAfterMidnight() == 3 * 60 then   
		game.Workspace.NTamb1Normal:Play()
	end
	wait()
end

and this:

while true do 
	if game.Lighting:GetMinutesAfterMidnight() == 3 * 60 then   
		game.Workspace.NTamb1Normal.Playing = true
	end
	wait()
end

I tried both Playing, isPlaying, Play()… and nothing is working.

6 Likes

Don’t have the sound it workspace, put it in soundservice, it’s playing it’s just that you can’t hear it from it’s destination.

4 Likes

Still doesn’t seem to be working.

2 Likes

Couple of things you should check:

  1. Make sure you’re within the actual sound MaxDistance (pretty sure they changed the name for it but I forget).

  2. Make sure the sounds volume isn’t 0

Lastly, and what I think is the culprit:

  1. The sound might actually be playing but since you have it within a loop with no checks (aside from the midnight), its constantly going to keep restarting. What I suggest is you add an additional check to make sure the sound isn’t already being played.
while true do 
	if game.Lighting:GetMinutesAfterMidnight() == 3 * 60 and not game.Workspace.NTamb1Normal.IsPlaying then   
		game.Workspace.NTamb1Normal:Play()
	end
	wait()
end

Might be typos as I am on mobile. Anyway hopefully this helps!

3 Likes

From my knowledge, you can’t use :Play() if the sound is located in SoundService. It must be in Workspace

8 Likes

How long is the audio and what type of script is it being told to be played(server or local)

3 Likes

It is a server script and the audio is looped (35.735)

2 Likes

Is the volume of the audio up to a good amount?

3 Likes

It is, I have also messed with the audio by turning it up to very high volume to test if its just quiet.

2 Likes

Have you tried removing the if statements and playing it normal to check if it would even play

3 Likes

Yes I have, this is what I did:

game.Workspace.NTamb1Normal.Playing = true

and it still didn’t work.

2 Likes

Try checking the audio’s playbackspeed, and you should also check if it has been moderated.

3 Likes

Did you try what I posted previously. If so and it still didn’t work than can you put a print(“whatever msg here”) right after the if statement.

2 Likes

I would try waiting until the sound is loaded:

repeat wait() until sound.IsLoaded
3 Likes

Yes I tried what you posted and print didn’t work either.

2 Likes

Tried it, didn’t work :[ and yes I added “local sound = thesoundimusing” (didnt use the format because not a long code)

2 Likes

So nothing got printed right? Now are you sure game.Lighting:GetMinutesAfterMidnight() == 3 * 60 is being met?

Right after while true do, print the following print(game.Lighting:GetMinutesAfterMidnight() == 3 * 60). Tell us whether its printing true or false

3 Likes

Doesn’t seem to be working. I even changed up the script: (sorry for the late response btw)

while true do 
	print("game.Lighting:GetMinutesAfterMidnight() == 3 * 60")
	if game.Lighting:GetMinutesAfterMidnight() == 3 * 60 then   
		game.Workspace.NTamb1Normal:Play()
	end
	wait()
end
2 Likes

Remove both " in the print as we dont want it to print as a string. Also do you mean nothing is printing or sound isn’t playing?

Make sure you have output open when testing. Go to view → output.

Note that printing is just for debugging so we can find out the issue. Its not a solution.

3 Likes

Even without the strings, nothing is happening, and I mean both, nothing is printing and sound is not playing.

2 Likes