Triggering Assignment Client Script with Entity Client Script?

Hello, I’m a bit new to HF and Javascript, so I apologize if this is a noob question, but I found nothing similar.

I am attempting to get a controllable npc working by using the Avatar recording tutorial found in this pdf here.

As a test for later functionality, I wanted to use this entity client script found here, modifying it so that it uses the Messages api to send a trigger message to the Assignment Client script that controls the npc.

Eventually, the goal is to have these messages trigger different recorded animations, but for now I just want the AC script to print a success message to the console when it receives a message.

Here is the modified segment of code from the entity client script:

Code snippet

this.mousePressOnEntity = function()

//Send Message
Messages.sendMessage("Channel", "Hello");


And here is the relevant code running on the assignment client:

Code Snippet

Messages.messageReceived.connect(function(channel, message, sender, localOnly)
//Test log

From my understanding, the “messageReceived” function in the messages API is supposed to trigger when a message is sent on a subscribed channel, but the assignment client isn’t printing to the sandbox log when I click the trigger entity.

Could anyone tell me what I’m doing wrong here?
Or, if I’m going about this the wrong way, could you point me in the right direction?

@humbletim @Menithal

I dont recall there being mousePressOnEntity being called by the controller scripts by default.
You would use Entities.mousePressOnEntity.connect to define a mouse press listener remotely from another script (so you can define a mousepress event listener, that will just return the id of the entity you clicked), however, in an entity script, by default, the C++ calls clickDownOnEntity instead.

So, use

this.clickDownOnEntity = function(id, event) {
   Messages.sendMessage("Channel", "Hello");


If you want vr controllers to work, you will have to then separately bind the controller events as well, but they behave a bit different from mouse clicks, so its best to wrap them

function interaction(id, event){
   Messages.sendMessage("Channel", "Hello");
function interactionWrap(event){
   interaction (, event)
this.preload = function(id){ = id;
this.clickDownOnEntity = interaction;
this.startFarTrigger = interactionWrap;
this.startNearTrigger = interactionWrap;

Some more reading regarding HF scripting.
Beyond the Wall of Scripts: Scripting in High Fidelity - Primer for Intermediate Programmers

Ah, I appreciate the reply.

However, the changeEntityColor(); function is called perfectly fine on click the way it is currently. The problem seems to be isolated either in the Messages.sendMessage call, or in the Messages.messageReceived.connect segment.

I’m led to believe this because while the entity’s color changes on click, no message is received by the Assignment Client script.

Do you happen to know why this is?