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

How can I make a Sound play on death?

Asked by 9 years ago

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.

0
dont ask for scripts. make your own, paste it here with the errors and we will help fix. NinjoOnline 1146 — 9y
0
Yes, this will be the last time I'll lend you scripts. Redbullusa 1580 — 9y
0
Sorry, I am a beginner and I don't know much to start off with. minikitkat 687 — 9y

2 answers

Log in to vote
0
Answered by
Redbullusa 1580 Moderation Voter
9 years ago

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

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! minikitkat 687 — 9y
Ad
Log in to vote
0
Answered by
Hybric 271 Moderation Voter
9 years ago

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

Answer this question