I highly recommend Keivit's article and scripts on OSF (https://osf.io/4bpmq/
), Henk & Castro-Schilo 2016 along with McArdle's 2009 annual rev is good.
None of this is worth it, if you don't have multiple tasks probing the same construct at both timepoints (it's okay to have missing data). Mauricio's code is the equivalent of subtracting t2 from t1 and looking at the relationship of that to your groups (delta ~ group), there's no point to do that in lavaan unless you'll do more (be careful in your interpretation; i.e. reversion to the mean).
If you only have 1 task pre and post and your treatment was randomized consider just using residualized-change in a linear model (t2 ~ randomized_IV + t1).
I'm not an expert on causality, yet I remember reading issues when you only have 2 timepoints (e.g. pre, post). Another consideration is that you need to have at least strong longitudinal measurement invariance (see keivit's scripts for strict).
Kievit, R., Brandmaier, A., Ziegler, G., van Harmelen, A.-L., de Mooij, S., Moutoussis, M., … Dolan, R. (2017). Developmental cognitive neuroscience using Latent Change Score models: A tutorial and applications (p. 110429). https://doi.org/10.1101/110429
Henk, C. M., & Castro-Schilo, L. (2016). Preliminary Detection of Relations Among Dynamic Processes With Two-Occasion Data. Structural Equation Modeling: A Multidisciplinary Journal, 23(2), 180–193.
Castro-Schilo, L., & Grimm, K. J. (2018). Using residualized change versus difference scores for longitudinal research. Journal of Social and Personal Relationships, 35(1), 32–58.
McArdle, J. J. (2009). Latent variable modeling of differences and changes with longitudinal data. Annual Review of Psychology, 60, 577–605.