Lerp Animation Problem

Dear Forum,

I am an experienced 3D animator but only a C# beginner and I have a (probably) very simple problem which I can´t solve on my own.

In a nutshell:

I have 4 objects (players) and three buttons placed between them. On clicking the buttons I want the objects left and right of the button to switch their positions. Due to the fact that the objects will be passed from button to button I need to check their positions and then decide wether to move them or not. The buttons call the SwitchPos() on click and the script is placed on a parent empty game object and checks the objects by their tag “asset3_objects”. Currently I only have one if clause running checking if an object has transform.x equals 4 and needs to be moved to 7

I use the following script:

using UnityEngine;
using System.Collections;

public class asset2_master_v2 : MonoBehaviour
{
    public GameObject[] players;
    public void SwitchPos()
    {
        players = GameObject.FindGameObjectsWithTag("asset3_objects");
        for (int i = 0; i < players.Length; i++)
        {
           // Debug.Log("Player Number " + i + " is named " + players*.transform.position.x);*

if(players*.transform.position.x==4)*
{
Debug.Log(“Object Number” + i + “fits”);
private float timeElapsed;
private float lerpDuration = 30f;
private float startValue = 4;
private float endValue = 7;
private float valueToLerp = players*.transform.position.x;*
valueToLerp = Mathf.Lerp(startValue, endValue, timeElapsed / lerpDuration);
timeElapsed += Time.deltaTime;
}
}
}
}
The Debug Log tells me that the object fits the position. Now when I add the Lerp components things start to go sideways and I get the error codes:
Assets\scripts\asset3\asset2_master_v2.cs(28,15): error CS1519: Invalid token ‘.’ in class, struct, or interface member declaration

Assets\scripts\asset3\asset2_master_v2.cs(28,36): error CS1519: Invalid token ‘;’ in class, struct, or interface member declaration
Where do I go wrong? I am probably pretty close but I am still learning and do not have the necessary knowledge to solve this on my own. I have read a bit on the Lerp function but the tutorials and documentation cover topics which are a lot more complex than this.
Thank you and best regards
Dunkel-san

Hey there, I removed the private keywords and that took care of the CS1519 errors, thank you very much. It still is not working however and now I get a new compilation error which reads

Assets\scripts\asset3\asset2_master_v2.cs(28,18): error CS0165: Use of unassigned local variable 'timeElapsed'

I then commented those parts out of the script (because the float did not have a value) and now it reads and still does not work. The debug message runs fine, but the Lerp animation is not working

using UnityEngine;
using System.Collections;

public class asset2_master_v2 : MonoBehaviour
{
    public GameObject[] players;


    public void SwitchPos()
    {
        players = GameObject.FindGameObjectsWithTag("asset3_objects");

        for (int i = 0; i < players.Length; i++)
        {
            if (players*.transform.position.x == 4)*

{
Debug.Log(“Object Number” + i + “fits”);

//float timeElapsed;
float lerpDuration = 3;

float startValue = 4;
float endValue = 10;
float valueToLerp = players*.transform.position.x;*

valueToLerp = Mathf.Lerp(startValue, endValue, lerpDuration);
// timeElapsed += Time.deltaTime;

}
}
}
}