How To Use PlayLocalSound

I’ve looked on the creator documents: SoundService | Roblox Creator Documentation

But nothing i try seems to work.

local SoundService= game:GetService("SoundService")
SoundService:PlayLocalSound(workspace.SpawnLocation.Sound)

This is an example. Is there somethin i’m doing wrong?

To add more clarity, this isnt when the player is in the game. this is when their in studio

1 Like

is this a local or server script?

1 Like

This is a local script

(Extra Characters)

1 Like

Try using this:

local sound = "your sound"

sound:Play()

use this script in a localscript

I dont think you can use PlayLocalSound on a LocalScript, but could be wrong.

1 Like

This doesnt seem to work either

Well i tried it through the command prompt too and i believe thats serversided

Does it give a error?
Where did you place the localscript?

No error. I tried the command bar but that doesnt work. the localscript was in StarterGUI

Can you give me more context of what you’re trying to do?

I’m trying to play a sound within a plugin

I’m going to need more then that

What do you mean? For example you press a button and it has a sound

Make a screenshot of the Explorer where the script is and paste whats in the script

image

local SoundService = game:GetService("SoundService")

local function playLocalSound(soundId)
	local sound = Instance.new("Sound")
	sound.SoundId = soundId
	SoundService:PlayLocalSound(sound)
	sound.Ended:Wait()
	sound:Destroy()
end


playLocalSound("rbxassetid://4645365277")
1 Like

When do you want the sound to play?

For now i’m trying to get it so it just plays

try using this: sound:Play()

Nothing happens

(extra characters :/)

It does for me and I don’t know what you’re doing wrong.