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

How can I make a Sound play on death?

Hello! i am working on a special death script in which when a player dies a gui that says "Wasted" pops up! I already have the visuals but now I don't know how to make a sound play when the player dies. I believe it needs to be inserted into the player for it to work.

3 comments

0

dont ask for scripts. make your own, paste it here with the errors and we will help fix.

0

Yes, this will be the last time I'll lend you scripts.

0

Sorry, I am a beginner and I don't know much to start off with.

2 answers

✓ Accepted answer

Ok, branching off from what I've answered in the last question you've asked, just add a sound play statement in your LocalScript:

s = script.Parent

s.Humanoid.Died:connect(function () -- If your humanoid died, this is triggered
	game.Players.LocalPlayer.PlayerGui.WastedGUI.Frame.Visible = true -- Assuming that your GUI's name is "WastedGUI" & its child is a Frame
	game.Players.LocalPlayer.PlayerGui.WastedGUI.Sound:Play() -- Playing sound statement, assuming you put the sound in the 'WastedGUI'
end)

Basic Schematic

Branching off from the last question I've answered from you

game < Players < LocalPlayer < PlayerGUI < WastedGUI < Sound

game < Players < LocalPlayer < PlayerGUI < WastedGUI < Frame < ImageLabel

1 comment

0

Okay thanks. I tried this on my own but instead of saying Sound:play() I put Sound:isPLaying. Thanks! Sorry for askign for whole script I am just a beginner and I just need some templates! This has finished my project so I probably won't be asking for many more scripts! Thanks again!

put a script in the StarterGui and put this inside script:

while wait(.1) do
if script.Parent.Parent.Character.Humanoid.Health <= 0 then
local x = Instance.new("ScreenGui", script.Parent)
local y = Instance.new("TextLabel")
y.Text = "WASTED"
y.Position = UDim2.new(0,0,0,0)
y.Name = "Label"
y.BackgroundTransparency = 1
local sound = Instance.new("Sound", script.Parent)
sound.SoundId = "rbxassetid://153239830"
wait()
sound:Play()
wait()
script:remove()
wait(2.7)
end
wait(.1)
end

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