error CS1955: The member 'UnityEngine.Vector3.x' cannot be used as method or delegate

using UnityEngine;
using System.Collections;

public class BallFollowBar : MonoBehaviour {

float barPos = GameObject.Find("PlayerMovingBar").transform.position.x;

// Use this for initialization
void Start () {
	
}

// Update is called once per frame
void Update () {
	transform.position.x(barPos);	
}

}

The code is very simple, but i feel like im missing something…

Here`s the error:
error CS1955: The member ‘UnityEngine.Vector3.x’ cannot be used as method or delegate

Anyone please can help me?

Welcome to Unity Answers!

In C#, parentheses are generally only used for defining and calling methods (such as Start()). Since you’re trying to set the x position, you would normally just assign the value directly, like this:

transform.position.x = barPos; 

However, “position” is actually a property, meaning that under the covers the code is calling a method to return the position to you, and as such you can’t set “x” directly. Here’s one way to do what you’re looking for:

	var cachedPosition = transform.position;
	cachedPosition.x = barPos;
	transform.position = cachedPosition;

I hear you guys and i appreciate the answer but what i want to know is how can i store all the x,y,z values of my object position at once and take them to the next scene?