Detect a square

I have a script that when you click the blue square, it creates line there, and then changes the player who makes the next move.
For example, red was randomly selected at the beginning and made a move then green was chosen etc.
How to make it detect a square made of lines, and who finished it?

[147078-ss2.png|147078]

Red finished the square in this case

[147079-ss1.png|147079]

Hello.

Very bad explanations. Blue are squares, and red is a player? you should say it… You say square for the blue litle squares and for the big closed area… dont use the same word…

It’s a simple solution, each blue square can only be aart of 4 complete areas, so just when creating a line, check if one of the areas have all 4 lines. Use coords and maths to know what lines need to check if exist.

Bye.