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

When a player dies, I want it to play a certain audio. I've already tried the died event Help?

Asked by 10 years ago

I tried the died event with an audio player script under it, but it is not working.~~~~~~~~~~~~~~~~~ game:GetService('Players').PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() print(player.Name .. " has died!") local s = Instance.new("Sound")

s.Name = "Sound" s.SoundId = "143796003" s.Volume = 3 s.Looped = false s.archivable = false

s.Parent = game.Workspace

wait(0)

s:play()

end end ~~~~~~~~~~~~~~~~~

3 answers

Log in to vote
0
Answered by
Damo999 182
10 years ago

Your script didn't work for 2 reasons, reason 1 would be that you did not have the url for the sound you just had numbers. Number two would be you need three ends at the end of the script with three of these braces )

1.the url should be http://www.roblox.com/asset/?id=143796003
2. end) end) end) 

--here is the script fixed 

game:GetService('Players').PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() print(player.Name .. " has died!") local s = Instance.new("Sound")

s.Name = "Sound" 
s.SoundId = "http://www.roblox.com/asset/?id=143796003" 
s.Volume = 3 
s.Looped = false
s.archivable = false
s.Parent = game.Workspace
wait(0)
s:play()

end)
end)
end)

Ad
Log in to vote
0
Answered by
Hybric 271 Moderation Voter
10 years ago

I'll give you an idea Intructions:

1. Create a LocalScript and a Script into ScreenGui 2. Put this inside both of the scripts:

while true do
wait(0.5)
if script.Parent.Parent.Character.Humanoid.Health <= 0 then
local s = Instance.new("Sound", game.Workspace)
s.SoundId = "rbxassetid://143796003"
s.Volume = 3
s.Looped = false
wait()
s:Play()
wait(5)-- put time amount to remove
s:remove()
end
end

ALSO YOUR SOUND ID SHOULD BE "rbxassetid://143796003"

0
Thanks! I'll try it. zachhg03 35 — 10y
Log in to vote
0
Answered by 10 years ago
s.SoundId = "http://www.roblox.com/asset/?id=143796003"

Answer this question