Limelight Code Erors

NetworkTable table = NetworkTableInstance.getDefault().getTable("limelight");

double leftThrottle = driver.getRawAxis(1)*-1;
double rightThrottle = driver.getRawAxis(5)*-1;

leftDrive.set(ControlMode.PercentOutput, leftThrottle*.15);
rightDrive.set(ControlMode.PercentOutput, rightThrottle*.15);

// float Kp = -0.1f;

// float tx = 

// if(driver.getRawButton(3)) {

//   float headingError = tx;
//   double steeringAdjust = Kp*tx;

// }

//read limelight variables
double x = tx.getDouble(0.0);
double y = ty.getDouble(0.0);
double valid = tv.getDouble(0.0);
double area = ta.getDouble(0.0);

The code shown above is the basics i have gotten for Limelight tracking. All the lines below //read limelight variables turn red for no apparent reason. Although, once i uncomment the “float tx=” line, all the errors below on those Limelight reading variables turn perfectly fine. I am wondering if this is a code error i am running into, or just something to do with the Limelight table itself.

Right after you define your network table, put in these lines of code:

NetworkTableEntry tx = table.getEntry(“tx”);
NetworkTableEntry ty = table.getEntry(“ty”);
NetworkTableEntry ty = table.getEntry(“tv”);
NetworkTableEntry ta = table.getEntry(“ta”);

Then you should be able to read those values later on

I have that in the robot init method. I have run this on another project of code that doesn’t have the tracking code in it which is shown being commented out at the moment. And in that other peice of code no issues what so ever. But I wanted another project for Vision Tracking so if it screws up I can go back, that is why I am having this problem at the moment and don’t understand why.