How To Make A Team or Private Chat

Script name: Open Input Modal For Private/Team Chat
show input modal to (owner of (last ability casting unit)) asking (Send A Private Message)
Run script (work private/team chat)
Script name: work private/team chat
for all players in (All players including both human & computer players (AI))
do:
if ((team) of (last triggering player)) == ((team) of (select players))
then do:
send chat message (last custom input of (triggering player)) to (selected player)