Can you please describe the actual gameplay you're trying to enable? While it's possible to query the players in a segment via the Server API (and so, by extension, in Cloud Script), that API call re-evaluates the full segment when it is called, so it should not be called as a result of a player action. If you can describe the actual experience you're trying to enable, we can advise you on the best approach.
1 Person is following this question.