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.
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
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