OK, take it one step at a time. For now let’s just say you need to add 3 pieces to consider it completed. And the Count script is the right way to focus. But we will also need to look at DragObject.
First, I don’t think you need anything in the Update method of the Count script. Update is for doing things on every frame; you will never need to change the piecesCount on every frame. Instead, you want to do it on certain events, namely when a piece is dropped (right?). So delete Update. I think you can also delete target, and all references to it, including the Start method.
Now let’s turn to DragObject. Are the “boom!” and “attached” debug messages appearing when you think it should? If so, that means you can identify the “a piece was dropped/attached” event correctly. So the next step is to turn that into an actual UnityEvent, so that other scripts can respond do it. Go watch this video to learn more about that.
Then add using UnityEngine.Events; to the top of DragObject, and add a public UnityEvent onDropped; property to your script. Finally, where the “attached” debug message is logged, add: onDropped.Invoke();
Now your DragObject is a properly event-friendly component that notifies interested parties when something interesting happens — namely, that a piece has been attached.
Now your Count script simply needs a public method to increment the count.
public void IncrementCount() {
piecesCount++;
Debug.Log("piecesCount is now: " + piecesCount);
}
Now, using the inspector, hook up the onDropped event of DragObject to the IncrementCount method of Count on each of your draggable objects. (Probably Count should live on one object in the scene, rather than on each draggable object… think that through, or experiment and see what works.)
When that’s working, then we can deal with firing another event when the count gets high enough, and using that to load the next level or whatever.