How do I place an object using anim events?

Hi, the problem may seem quite obvious. I got an animation, which slides out my pause panel. After that I want this panel to teleport to the (-550, 0, 0). So I made this animation event that shall be called just when the slideOut animation ends.

And I have a script that should place an object to the specified coordinates:

public class PausePanelAnimationController : MonoBehaviour
{
    [SerializeField]
    private GameObject pausePanel;

    public void PlaceObjectTo(float x)
    {
        Vector3 @newposition = new Vector3(x, transform.position.y);
        pausePanel.transform.position = newposition;

        Debug.Log("New object's position: " + pausePanel.transform.position.ToString());
    }
}

But it doesn’t work, even though I clearly see that the function is being called.

What should I do?

If you are using a panel under Canvas, transform won’t work.
You need to update RectTransform values.

Here’s the documentation on RectTransform values: Unity - Scripting API: RectTransform