WM/WatermelonCollect10.cs

A component that listens for trigger enter events to collect a watermelon. On trigger it increments a global ScoreManager counter, sets a flag indicating the 10th watermelon was collected, plays a configured sound, and then destroys its GameObject on the next update when the flag is set.

using Sandbox; 

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

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

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