Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can anyone help with this audio on death script?

I have an audio on death script right here, and it used to work in the other games I had used it in.

id = "172294682" t = 10 Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=172294682") repeat wait() until game.Workspace:findFirstChild(script.Parent.Parent.Name) sound = script.Sound sound.SoundId = "http://www.roblox.com/asset/?id=172294682" char = script.Parent.Parent.Character print("TOO BAD") char.Humanoid.Died:connect(function() print("Died") sound:Play() wait(t) Sound:Stop() end)

I have been toying around with it, but no matter what I do, it doesn't seem to work. I have the sound file uploaded and everything else, but I just don't understand what can be causing the problem.

1 answer

✓ Accepted answer

Try this (this might be what you have, but it should work). Make sure this is a LocalScript and it is in the StarterGui or Backpack.

local ContentProvider = game:GetService('ContentProvider')
local Player = game.Players.LocalPlayer
local Character = game.Workspace:WaitForChild(Player.Name)
local Humanoid = Character:WaitForChild('Humanoid')
local Sound = Instance.new('Sound', Player.PlayerGui)
Sound.SoundId = "http://www.roblox.com/asset/?id=172294682" --Insert your sound Id here
ContentProvider:Preload(Sound.SoundId)

Humanoid.Died:connect(function()
	Sound:Play()
	--Sound will automatically stop playing when the player respawns
end)

3 comments

0

Alright, I'll try out this alternative. Thanks.

0

Yes, it's all working fine now. Thank you for the help.

0

No problem.

This discussion is preserved as it was. New answers, comments, and votes are closed.