DeathScreen Gui Doesn't show up every time I die

So I have my own deathscreen that plays whenever a player dies, but for some reason the deathscreen only pops ups most the time, but sometimes it randomly doesn’t pop up, I have no idea what causes this random bug, here is the script:

wait()
local players = game.Players
local t = 2
players.PlayerAdded:Connect(function(player)
   player.CharacterAdded:Connect(function(character)
   	local humanoid = character:WaitForChild("Humanoid")
   	local gui = player.PlayerGui:FindFirstChild("DeathScreen")
   	
   	humanoid.Died:Connect(function(died)
   		player.PlayerGui:FindFirstChild("DeathScreen"):WaitForChild("ImageLabel").Visible = true
   		local f = game.TweenService:Create(player.PlayerGui:FindFirstChild("DeathScreen"):WaitForChild("ImageLabel"), TweenInfo.new(0.6, Enum.EasingStyle.Linear, Enum.EasingDirection.In), {["ImageTransparency"] = 0.1})
   		f:Play()
   		wait(1.3)
   		local e = game.TweenService:Create(player.PlayerGui:FindFirstChild("DeathScreen"):WaitForChild("ImageLabel"), TweenInfo.new(1.2, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), {["ImageTransparency"] = 1})
   		e:Play()
   		
   		for i = t, 0, -1 do
   			player.PlayerGui:FindFirstChild("DeathScreen").ImageLabel.Timer.Text = " "..i
   			wait(1)
   		end
   		player.PlayerGui:FindFirstChild("DeathScreen").ImageLabel.Timer.Text = " 3"
   		player.PlayerGui:FindFirstChild("DeathScreen"):WaitForChild("ImageLabel").Visible = false
   		local e = game.TweenService:Create(player.PlayerGui:FindFirstChild("DeathScreen"):WaitForChild("ImageLabel"), TweenInfo.new(0.7, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), {["ImageTransparency"] = 1})
   		e:Play()
   		
   	end)
   end)
end)

also, the glitch only occurs when a player joins the game, for example, if i join the game and die and the deathscreen pops up then it will keep popping up consistently whenever I die, but if i join the game and die and the deathscreen doesn’t pop up then it wont pop up whenever i die unless I rejoin the game and keep rejoining until the deathscreen pops up again when i die

Well the bug only appears to happen in studio, not in the real game so I guess I don’t need a fix since it doesn’t effect gameplay