the undo just undoes clicking on the object not modifying the value. After some research I tried Undo.RecordObject(serializedObject