Sounds not playing when parented to player?

I have a sound that is parented to a player when they join a game:

local sound = SoundService:WaitForChild("TheSound")

game:GetService("Players").PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        local soundClone = sound:Clone()
        soundClone.Name = "SoundSound"
        soundClone.Parent = player
    end)
end)

And then later played via a sever-script:

if game.Players:FindFirstChild(player.Name):FindFirstChild("SoundSound") then
    game.Players:FindFirstChild(player.Name):FindFirstChild("SoundSound"):Play()
end

The sound plays fine when I manually play it in Studio, however, it doesn’t in-game.

Have you tried putting a print statement in this. Maybe its not running at all. Show us the whole server script

You can try this

also what is the character for?
player.CharacterAdded:Connect(function(character)

It is running. I put a print statement in it.

if game.Players:FindFirstChild(player.Name):FindFirstChild("SoundSound") then
    print("TEST")
    game.Players:FindFirstChild(player.Name):FindFirstChild("SoundSound"):Play()
end

It prints TEST every time. :confused:

The player.CharacterAdded:Connect(function(character)) fires when the Character fully loads. So, I want the game to add the Sound to the player once his Character fully-loads.

You’re parenting the sound under the player instance, sounds don’t work unless they’re are a descendant of the workspace. So you should patent it to the character model instead.

1 Like