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.

5 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.

3 Likes

Still doesn’t seem to be working.

1 Like

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!

2 Likes

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

7 Likes

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

2 Likes

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

1 Like

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

2 Likes

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

1 Like

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

2 Likes

Yes I have, this is what I did:

game.Workspace.NTamb1Normal.Playing = true

and it still didn’t work.

1 Like

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

2 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.

1 Like

I would try waiting until the sound is loaded:

repeat wait() until sound.IsLoaded
2 Likes

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

1 Like

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

1 Like

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

2 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
1 Like

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.

2 Likes

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

1 Like