diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 679b9b847f..90cd3b1a68 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -3957,7 +3957,18 @@ namespace OpenSim.Region.ScriptEngine.Common UUID key = new UUID(); if (UUID.TryParse(id, out key)) { - return World.GetSceneObjectPart(World.Entities[key].LocalId).OwnerID.ToString(); + try + { + SceneObjectPart obj = World.GetSceneObjectPart(World.Entities[key].LocalId); + if (obj == null) + return id; // the key is for an agent so just return the key + else + return obj.OwnerID.ToString(); + } + catch (KeyNotFoundException) + { + return id; // The Object/Agent is not in the region so just return the key + } } else { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index d2cfdca52d..110ece4c89 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3815,7 +3815,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID key = new UUID(); if (UUID.TryParse(id, out key)) { - return World.GetSceneObjectPart(World.Entities[key].LocalId).OwnerID.ToString(); + try + { + SceneObjectPart obj = World.GetSceneObjectPart(World.Entities[key].LocalId); + if (obj == null) + return id; // the key is for an agent so just return the key + else + return obj.OwnerID.ToString(); + } + catch (KeyNotFoundException) + { + return id; // The Object/Agent not in the region so just return the key + } } else {