Help limitig the player position

hello im new in the world of C sharp. and i need help :slight_smile:

I want to limit the player position

if (transform.position.x > 5 )
{
tranform.position.X =5 // i cant because tranform.position is not a variable
}
Help

h = transform.position;

if (h.x >5)
{
h.x = 5;
transform.position = h;
}

i resolved the issue but now the object just keeps moving really slowy when he reach the position.x= 5 and keeps moving more than 5 :X