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

Can anyone help with this audio on death script?

Asked by 9 years ago

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

Log in to vote
1
Answered by 9 years ago

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)
0
Alright, I'll try out this alternative. Thanks. xDeterminedx 5 — 9y
0
Yes, it's all working fine now. Thank you for the help. xDeterminedx 5 — 9y
0
No problem. LordSpectrus 25 — 9y
Ad

Answer this question