Greet the room in chat
Updated
Connects to chat once the scene is drawn, retrying a few times, waits for the snapshot to be ready and sends one greeting to the general conversation.
Read the log. The preview has no Arena room, so after a few retries the script says chat is not available; in a published world it greets everyone once.
Greet the room in chat
#pragma lifecycle(startup)
// Connect once play has drawn the scene, retrying a few times.async function connectChat(tries = 5) { for (let i = 0; i < tries; i++) { if (await Chat.connect()) return true; await new Promise((done) => delay(done, 1000)); } return false;}
async function startup() { if (!(await connectChat())) { log('Chat is not available here'); return; } let greeted = false; Chat.subscribe(async (snapshot) => { if (greeted || !snapshot.ready) return; greeted = true; await Chat.sendGeneral('Hello everyone!'); });}How it works
Section titled “How it works”The script is explained step by step in Greet the room in chat.
Open it in XR Creator
Section titled “Open it in XR Creator”Download the project file below, then import it in XR Hub with Projects › New › Import, as described in Projects and templates. It opens in XR Creator with the same scene you see running above, each script already attached to its Behavior entity. From there you can edit the scripts, adjust components and their props, preview your changes, and deploy the result as a world of your own.
ChatGreeter.xrproj