BGE toggle select object
Messages

This is a logic brick only solution. It should be sufficient at the situation you described.

Selection handling

In this sample we let selectable object store the selection status in a property called "selected". 

When it is "True" the object is selected. 

When it is "False"  the object is not selected.

Give all selectable objects the property "selected" as boolean


Deselect all

When clicking anywhere send a message "deselect".

Any selectable object listens to a message "deselect" and deselects itself on receipt.



You need a (single) managing object that triggers this deselection.



With that you ensure on any right click all objects are deselected.

Select one

The one object the mouse cursor is over will be selected.



You see the selection will take place on the object under the cursor only. All other object will still receive the "select" message but ignore them.

Now let's make your managing object send the "select" messages:


It looks pretty much the same as the "deselect" logic. This is as both are triggered by the same key.

What will happen?

One left click:


message "deselect" will be send to all objects with message sensor listening to "deselect"
message "select" will be send to all objects with message sensor listening to "select"


[all selectable objects receive two messages!]


All selectable objects willreceive "deselect" and set property "selected" to False
All selectable objects will receive "select" 


the one with the cursor over it will set property "selected" from (previously set) "False" to "True"
all others do nothing and keep "selected" with "False"



This way you can be sure only one can be selected as only one can have the mouse cursor above it.