functionopenWidget(p){//Check if player is mobile or notif(p.isMobile)//Set the widget's name, anchor position, width, and height.p.tag.widget =p.showWidget('widget.html','sidebar',300,550);elsep.tag.widget =p.showWidget('widget.html','sidebar',280,520);//Send data to widgetp.tag.widget.sendMessage({ isMobile :p.isMobile, })//Register events for messages sent from widgetsp.tag.widget.onMessage.Add(function(sender, msg) {switch (msg.type) {case'close':if(p.tag.widget) {p.tag.widget.destroy();p.tag.widget =null; }break;case'submit':let choiceItem =msg.choice;p.showAlert('Item'+ choiceItem);break; } })}//Event when a player joins the appApp.onJoinPlayer.Add(function(p) {//Reset the player's tag valuep.tag = {};});// Action when the player clicks the sidebar appApp.onSidebarTouched.Add(function(p) {openWidget(p);});