FloatingDamageNumber.cs

A simple game Component that tracks time since creation and destroys its GameObject after one second. It stores a RealTimeSince and checks it each update, calling GameObject.Destroy() when the timer exceeds 1 second.

using Sandbox;

public class FloatingDamageNumber : Component
{
	private RealTimeSince _timeSince;

	protected override void OnAwake()
	{
		base.OnAwake();

		_timeSince = 0f;
	}

	protected override void OnUpdate()
	{
		base.OnUpdate();

		if ( _timeSince > 1f )
			GameObject.Destroy();
	}
}