Help with making Drivetrain available for a certain function only

Hello so let’s get to the point: I am making a mecanum base with my team but we want to use a vex drivetrain inside the autonomous function. However, the drive train is available for all the code so it make our base go a LITTLE BIT HOT (we we’re able to do 7 minute without dying now it’s 3 MINUTES ONLY)

I tried to put Private infront of : smartdrive AutonomusDriveTrain = smartdrive(LeftSide,RightSide, Inertial10); but it just gave me an error

Here is the code:

int autonomousmode() {
  smartdrive AutonomusDriveTrain = smartdrive(LeftSide,RightSide, Inertial10);
  AutonomusDriveTrain.setDriveVelocity(100,percent);
  AutonomusDriveTrain.setTurnVelocity(100,percent);

  AutonomusDriveTrain.driveFor(forward,200.0,mm,true);
  AutonomusDriveTrain.turnToHeading(90, degrees);
 // drivetrain AutonomusDriveTrain = drivetrain();
  Brain.Screen.print("\033[30m");
  return 0;
}

thank you in advance!

well i don’t need help anymore i found that i can use the keyword: static