// Script written by Thoys, mainly for fun , feel free to use it for anything (function() { function setAttachments(attachmentModel, scale) { var hatAttachmentData = { Head: { jointName: 'Head', modelUrl: attachmentModel, rotation: { x: -27, y: 0, z: 0 }, scale: 0.9, soft: false, translation: { x: 0, y: 0.130, z: -0.01 } } }; print ('attaching'); var currentAttachments = MyAvatar.getAttachmentsVariant(); var newAttachments = []; newAttachments.push(hatAttachmentData['Head']); currentAttachments.forEach(function(attachment) { if (attachment.jointName !== hatAttachmentData['Head'].jointName) { newAttachments.push(attachment); } }); MyAvatar.setAttachmentsVariant(newAttachments); } var attachTheModel = function(entityID) { var properties = Entities.getEntityProperties(entityID, ['modelURL', 'dimensions']); setAttachments(properties.modelURL, Math.max.apply(Math, [properties.dimensions.x, properties.dimensions.y, properties.dimensions.z])); }; this.startNearTrigger = function(entityID, args) { print('ha'); attachTheModel(entityID); }; this.clickReleaseOnEntity = function(entityID, mouseEvent) { print('ha'); attachTheModel(entityID); }; })