Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Sound on Death? [closed]

Asked by 9 years ago

I have been trying to make this sound play on death. I have tried everything with my meager knowledge of scripting and come up short. Does anyone have any ideas? The code block is the on death function, but i cannot understand anything related to sound. Anyone mind helping me add the play sound function?

game:GetService('Players').PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()
            print(player.Name .. " has died!")
        end)
    end)
end)

Locked by TheMyrco

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
TopDev 0
9 years ago

Try this!

SID = 157707359 -- Sound ID goes here if you ever need to change it.

game:GetService('Players').PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()
            local s = Instance.new("Sound", player.Backpack)
              s.SoundId = "http://www.roblox.com/asset/?id="..SID
              s:Play()
        end)
    end)
end)

0
Alright I am going to try this SinsofFallenGods 50 — 9y
0
You need a medal trytoeatme SinsofFallenGods 50 — 9y
0
Thanks! Glad it worked, happy to help you. TopDev 0 — 9y
Ad