diff --git a/Source/Plugins/UDBScript/API/MapElementArgumentsWrapper.cs b/Source/Plugins/UDBScript/API/MapElementArgumentsWrapper.cs
index 19f5e1cd0fcdbbb29fc84fc962e60d7ac7c96e43..91531c80d7639693d4bad9f7cc5bf83b1ba29d26 100644
--- a/Source/Plugins/UDBScript/API/MapElementArgumentsWrapper.cs
+++ b/Source/Plugins/UDBScript/API/MapElementArgumentsWrapper.cs
@@ -51,8 +51,18 @@ namespace CodeImp.DoomBuilder.UDBScript.Wrapper
 			}
 			set
 			{
-				if (element is Thing) ((Thing)element).Args[i] = value;
-				else if (element is Linedef) ((Linedef)element).Args[i] = value;
+				if (element is Thing)
+				{
+					// We're not directly changing the fields, but apparently that's the only way to record the changes for the undo system
+					((Thing)element).Fields.BeforeFieldsChange();
+					((Thing)element).Args[i] = value;
+				}
+				else if (element is Linedef)
+				{
+					// We're not directly changing the fields, but apparently that's the only way to record the changes for the undo system
+					((Linedef)element).Fields.BeforeFieldsChange();
+					((Linedef)element).Args[i] = value;
+				}
 			}
 		}