Hello, developers! I am trying to make a plugin and add some sound effects but none of them have been working. I used the document article linked to make it work: SoundService:PlayLocalSound. I tried this and the audio still does not play. I have read through other articles and none of them help with what I am trying to do. The audio I am using is not owned by me. Thank you for any help in advance!
local toolbar = plugin:CreateToolbar("Discoro Feedback Hub!")
local SoundService = game:GetService("SoundService")
local gui = script.Parent.Parent.MainUI
gui.Parent = game.CoreGui
local menuButton = toolbar:CreateButton(
"Open/Close the Discoro Feedback Hub!",
"Explore the Discoro Feedback Hub!",
"",
"Open/Close the Discoro Feedback Hub!"
)
local function playLocalSound(soundId)
-- Create a sound
local sound = Instance.new("Sound")
sound.SoundId = soundId
sound.Parent = gui
-- Play the sound locally
SoundService:PlayLocalSound(sound)
-- Once the sound has finished, destroy it
sound.Ended:Wait()
sound:Destroy()
end
menuButton.Click:Connect(function()
if gui.MainFrame.Visible == false then
gui.MainFrame.Visible = true
gui.BackgroundFrame.Visible = true
playLocalSound("rbxassetid://7143514450")
else
gui.MainFrame.Visible = false
gui.BackgroundFrame.Visible = false
playLocalSound("rbxassetid://7143514450")
end
end)