So, when my guy dies, I want there to be a screen that says "you died". I tried making this, and it wouldn't work. Here is my code, with a lot of notes.
game:GetService('Players').PlayerAdded:connect(function(player) --getting service
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function() -- checks for death
print(player.Name .. " has died!")
local f = script.Parent.Parent --variable
local txt = script.Parent --variable
f.BackgroundTransparency = 1
txt.BackgroundTransparency = 1
txt.TextTransparency = 1
local i = 0 --variable
while wait(0.01) do --fade effect start
f.BackgroundTransparency = f.BackgroundTransparency - 0.01 --lose transparency
txt.BackgroundTransparency = txt.BackgroundTransparency - 0.01 --lose transparency
txt.TextTransparency = txt.TextTransparency - 0.01 --lose transparency
if txt.BackgroundTransparency == 0.8 then --if at wanted position then
f.BackgroundTransparency = 0
txt.TextTransparency = 0
i = "stop"
break --ends the script
end
--if not at wanted position, then retry
end
end)
end)
end)
while wait() do --check if death screen should end
if i == "stop" then
wait(5)
i = 0
local f = script.Parent.Parent -- renaming variable
local txt = script.Parent -- renaming variable
txt.BackgroundTransparency = 1
f.BackgroundTransparency = 1
txt.TextTransparency = 1
end
end
So, that's basically my code. When I check the output, there are no errors. Please help me out!

1 comment