I have this script that makes a Gui Appear and a Sound to play when you die.
The problem is, the Gui Appears, but the Sound plays only after respawn.
I have tried waiting longer times and dying many times, but it still plays after the respawn.
This is the script I used:
P = script.Parent.Parent.Parent.Parent.Character.Humanoid while true do if P.Health == 0 then script.Parent.Parent.Parent.Death:Play() script.Parent.Visible = true end wait() end
P = script.Parent.Parent.Parent.Parent.Character.Humanoid while true do if P.Health == 0 then script.Parent.Parent.Parent.Death:Play() script.Parent.Visible = true end wait() end
What this script does is it constantly checks if Health is 0, and when it is, plays a sound. What's wrong with that is that when Health is 0, it plays the audio and then keeps checking if health is 0, causing the audio to keep playing until health isn't 0 (When you respawn).
A working version of your script would be:
P.Died:connect(function() --When P dies, do the following script.Parent.Parent.Parent.Death:Play() script.Parent.Visible = true end)
You can use the Died event to tell when a humanoid has died.
P.Died:connect(function() script.Parent.Parent.Parent.Death:Play() script.Parent.Visible = true end