WM/WatermelonCollect9.cs

A component that listens for trigger enters to collect a watermelon pickup. On trigger it increments a global ScoreManager WMCount, sets WM9collect to true, plays a sound, and on update destroys its GameObject if WM9collect is true.

using Sandbox; 

public sealed class WatermelonCollect9 : Component, Component.ITriggerListener
{
	[Property] public SoundEvent melon { get; set; }
	void ITriggerListener.OnTriggerEnter( Collider collision )
	{

		ScoreManager.WMCount += 1;
		ScoreManager.WM9collect = true;
		GameObject.PlaySound( melon );

	}
	protected override void OnUpdate()
	{
		
		if ( ScoreManager.WM9collect)
		{
			GameObject.Destroy();
			
		}
	}
	
}