Programmatically lock rotation axis not working

Hi!

I’m trying to lock the physics rotation axis programmatically using c++.
Here’s my code I’m using (exposed to and called from blueprints), but it’s not working:

void UUtility::SetRotationAxisLock(UPrimitiveComponent* Component, const bool bLockX, const bool bLockY,
                                   const bool bLockZ)
{
	Component->BodyInstance.bLockXRotation = bLockX;
	Component->BodyInstance.bLockYRotation = bLockY;
	Component->BodyInstance.bLockZRotation = bLockZ;
}

Do you have an idea on how to fix this or is there another way to change the rotation lock constraints during runtime from blueprints?
Thank you very much!