Also, make sure you’ve set the team number in the limelight interface to match the team number on your robot. What you are probably seeing is the default value that network tables returns when it didn’t actually find the table.
Fire up Shuffleboard and verify the values are the same as to what key you are using when you add the limelight table to shuffleboard it should all be there visible to you as well.
Have you checked the return value from the getValue is not kUnassigned? Or, if so, can you enumerate the keys of what you see and see why your code seems to be missing them?
First the code is in public class Robot extends IterativeRobot (right under it to be exact), no periodic stuff, second, whenever I print the getValue(): System.out.println(targetx.getValue());
getValue() returns a NetworkTableValue, which is basically a typed union, as NetworkTable values can be one of several possible types. The methods on NetworkTableValue can be used to figure out what type the value is, get the underlying data, etc.
However, there are more specific methods for individual data types on NetworkTableEntry to make things easier. If you know the type is e.g. a double, it’s much easier to use NetworkTableEntry.getDouble(), which simply returns a double.