WM/WatermelonCollect7.cs

A game component that listens for trigger enter events to count collection of a specific watermelon (index 7). On trigger it increments a global ScoreManager counter, sets a collected flag, plays a sound, and on update destroys its GameObject if the collected flag is set.

using Sandbox; 

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

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

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