diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 730677d85d..2cefd647cb 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -498,12 +498,12 @@ void EntityScriptingInterface::deleteEntity(QUuid id) { auto nodeList = DependencyManager::get(); const QUuid myNodeID = nodeList->getSessionUUID(); - auto avatarHashMap = DependencyManager::get(); - AvatarSharedPointer myAvatar = avatarHashMap->getAvatarBySessionID(myNodeID); if (entity->getClientOnly() && entity->getOwningAvatarID() != myNodeID) { // don't delete other avatar's avatarEntities - // If you actually own the entity but the onwership is not set because of a domain switch - // the line below make sure the entity is deleted. + // If you actually own the entity but the onwership property is not set because of a domain switch + // The lines below makes sure the entity is deleted once its properties are set. + auto avatarHashMap = DependencyManager::get(); + AvatarSharedPointer myAvatar = avatarHashMap->getAvatarBySessionID(myNodeID); myAvatar->insertDetachedEntityID(id); shouldDelete = false; return;