Is there a way to play a sound using a plugin?

Hello Developers!

I was recently working on a plugin that is basically all sounds. Nope you’re not gonna get the plugin name yet🤷‍♂️. And I wanted to play a sound once a button is clicked. I tried to clone the sound to workspace and playing it there, but didn’t work. Is there a way to “preview” the sound thru scripts?

Any Help is appreciated,

1 Like

Try using SoundService:PlayLocalSound(Sound). (You put in a sound instance in the argument) Read more here: SoundService | Roblox Creator Documentation

1 Like

Perfect. You just made me eat cake.

Glad I could help! In the documentation page, it provides this function:

local function playLocalSound(soundId)
	-- Create a sound
	local sound ="Sound")
	sound.SoundId = soundId
	-- Play the sound locally
	-- Once the sound has finished, destroy it

Which allows you to put in a SoundId rather than a sound instance. It just makes it a bit easier if you’re working with SoundIds.

I don’t think the sound service works? Been trying it, and audio still doesn’t play. Keeping in mind the new updates to audio roblox just pushed out.

I’m in the same boat. SoundService doesn’t seem to be complying :frowning:

Sounds mounted under plugin guis (CreateDockWidgetPluginGui) play sounds.

I’m using a DockWidgetUI, and it won’t work if you use CoreGui.

I wouldn’t recommend CoreGui anyway, since studio has way more features in DockWidgets.

Thanks! I wish they mentioned this in the SoundService API :frowning: