Character soundboard

I am making a script where you click the gui button then an audio plays and the whole server can hear it. My script dosent work. Any help?

Startergui script


-- LocalScript inside the GUI Button
local button = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local playSoundEvent = ReplicatedStorage:WaitForChild("PlaySoundEvent")

button.MouseButton1Click:Connect(function()
    playSoundEvent:FireServer()
end)

A remote event is placed

Server script service script


-- Script in ServerScriptService
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local playSoundEvent = ReplicatedStorage:WaitForChild("PlaySoundEvent")

playSoundEvent.OnServerEvent:Connect(function(player)
    local character = player.Character
    if not character then return end

    local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
    if not humanoidRootPart then return end

    -- Create the sound object
    local sound = Instance.new("Sound")
    sound.SoundId = "rbxassetid://<YOUR_SOUND_ID>" -- Replace <YOUR_SOUND_ID> with the sound's asset ID
    sound.Parent = humanoidRootPart
    sound.Volume = 1 -- Adjust volume as needed
    sound:Play()

    -- Cleanup sound object after it finishes
    sound.Ended:Connect(function()
        sound:Destroy()
    end)
end)

You are changing the Sound id right? Also maybe change MouseButton1Click to Activated.

1 Like

It seems like there is no problem. did any errors occur?

no sound coming in. i did try anything

Is this the actual line in your script? If so, you need to replace <YOUR_SOUND_ID> with a proper asset ID.

Do you have a sound id inserted in there?

yes i did replace it. i sended the script without the ID

yes i am sending the one without the ID

Maybe remove the character and root part checks and test it like that, mightve messed something up there

If it genuinely doesn’t work even with the ID, I would recommend adding debug prints to track where the prints stop, especially where you’re firing the event and receiving it, and during the root part and character checks

2 Likes