How do I check if an audio isn't playing on the server side?

What I’m Attempting

So, i’m trying to make it where when a phrase is said… an audio will play and then once that audio is done… it will be deleted… the only issue is I have no way of checking to see if the audio is playing or not.

What i’ve tried

I’ve tried changing my style to the .Playing system but that mainly works through the local system and that didn’t work…

Script

--Made By MillerrIAm
--------Variables-------
SoundName = "What" --Change this to the sounds name
SSound = game:GetService("ServerStorage").CrowdSounds
WSound = game:GetService("Workspace").CrowdSounds
----------- Messages -----------
--[[Change these below to what you want people to say to activate the sound.]]--
msg1 = "What" 
msg2 = "what"
msg3 = "wat" 
msg4 = "Wat"
--------Main Code------
game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		if msg == msg1 or msg == msg2 or msg == msg3 or msg == msg4 then
			if not WSound:FindFirstChild(SoundName) then
				SSound[SoundName].Volume = 1
				SSound[SoundName]:Clone().Parent = WSound
				WSound[SoundName]:Play()
				if not WSound[SoundName]:Play() then
					WSound[SoundName]:Stop()
					WSound[SoundName]:Destroy()
				end
			end
		end
	end)
end)

To do that, you can set Sound.PlayOnRemove to true and delete the sound. Sound will delete and it will play. Note that when using this method, you should not call :Play() or .Playing = true.

1 Like

The Sound has an event called Ended that fires when the playback stops. You can wait for the sound to end simply with this line:

Sound.Ended:Wait()

Person above has a good solution too. ^

2 Likes