"Sinu", I'm no expert, but can it not be done with smaller code by "toggling" with a "Not","If",Else" structure (If "whatever" Then ShowEntity "xxx" Else HideEntity "xxx"? Taking into account Entityvisible=Not Entityvisible
Edited post - mmm, perhaps not thinking about it with aftersight (the above just instantly popped into my head) - sorry
Edited post - mmm, perhaps not thinking about it with aftersight (the above just instantly popped into my head) - sorry