diff --git a/FRBDK/Glue/Glue/SaveClasses/NamedObjectSaveExtensionMethods.cs b/FRBDK/Glue/Glue/SaveClasses/NamedObjectSaveExtensionMethods.cs index 5bcc45a50..21a4b90a0 100644 --- a/FRBDK/Glue/Glue/SaveClasses/NamedObjectSaveExtensionMethods.cs +++ b/FRBDK/Glue/Glue/SaveClasses/NamedObjectSaveExtensionMethods.cs @@ -510,8 +510,20 @@ public static void SetVariable(this NamedObjectSave instance, string variableNam } else { - var type = value?.GetType(); - instruction = instance.AddNewGenericInstructionFor(variableName, type); + // If it comes from an entity, try to assign the type from the entity. This is needed if the variable + // is an Entity.Type property + var nosEntity = ObjectFinder.Self.GetEntitySave(instance); + var variable = nosEntity?.GetCustomVariableRecursively(variableName); + + if(variable != null) + { + instruction = instance.AddInstruction(variableName, variable.Type); + } + else + { + var type = value?.GetType(); + instruction = instance.AddNewGenericInstructionFor(variableName, type); + } } }