# Troubleshooting

#### Troubleshooting

If you encounter any issues while using the **b2\_vehicleEssentials** script, refer to the troubleshooting steps below to diagnose and resolve common problems.

**Common Issues**

1. **Script Not Starting**
   * **Problem**: The script does not start when the server is launched.
   * **Solution**: Ensure that you have added `start b2_vehicleEssentials` to your `server.cfg` file. Verify that the script is placed in the correct `resources` folder.
2. **Traffic Density Not Adjusting**
   * **Problem**: Dynamic traffic management does not seem to work.
   * **Solution**: Check if `Config.DynamicTrafficManagement` is set to `true` in the `config.lua` file. Ensure the server population is being tracked correctly.
3. **Seatbelts Not Working**
   * **Problem**: Automatic or manual seatbelts are not functioning as expected.
   * **Solution**: Verify that `Config.AutoSeatbeltOnEntry` is set to `true` for automatic seatbelts. For manual seatbelts, ensure the `Config.SeatbeltKey` is correctly configured and not conflicting with other keybindings.
4. **Speed Limiter Not Applying**
   * **Problem**: Speed limits are not being enforced.
   * **Solution**: Ensure `Config.SpeedLimiterEnabled` is set to `true`. Check the `Config.GlobalSpeedLimit` and `Config.SpeedZones` settings for correct values.
5. **Realistic Vehicle Damage Not Applied**
   * **Problem**: The realistic vehicle damage system is not working.
   * **Solution**: Verify that `Config.DamageSystem.enabled` is set to `true`. Ensure that the individual settings within the `DamageSystem` configuration are correctly set.
6. **NPC Driving Style Not Changing**
   * **Problem**: NPC driving styles are not changing as expected.
   * **Solution**: Confirm that `Config.MentalState.DrivingStyle` is set to a valid driving style value. Use the export `exports.b2_vehicleEssentials:ChangeNPCDrivingStyle(drivingStyle)` correctly in other scripts.
7. **Vehicles Giving Weapons**
   * **Problem**: Vehicles are still giving weapons to players despite the setting.
   * **Solution**: Check if `Config.DisableVehicleWeapons` is set to `true`. Ensure the script loop responsible for disabling vehicle weapons is running without errors.
8. **Performance Issues**
   * **Problem**: The script is causing high CPU usage.
   * **Solution**: Make sure you are running the latest optimized version of the script. Review the configuration settings to avoid overly frequent operations. Set `Config.Debug` to `false` in production to reduce logging overhead.

**Debugging Steps**

1. **Enable Debug Mode**
   * Set `Config.Debug` to `true` in the `config.lua` file to enable detailed debug prints. This will help in identifying issues by providing more information in the console.
2. **Check Server Console**
   * Review the server console logs for any error messages or warnings related to the **b2\_vehicleEssentials** script. Look for missing dependencies or configuration errors.
3. **Validate Configuration**
   * Double-check all configuration settings in the `config.lua` file. Ensure all values are correct and within acceptable ranges.
4. **Update Script**
   * Ensure you are using the latest version of the **b2\_vehicleEssentials** script. Check the Github Repository for any updates or bug fixes.
5. **Disable Conflicting Scripts**
   * Temporarily disable other scripts to identify any potential conflicts. Gradually re-enable them to pinpoint the source of the issue.

**Contact Support**

If you have tried the above troubleshooting steps and are still experiencing issues, feel free to reach out for support on the GitHub Repository or the Discord. Provide detailed information about your problem, including any error messages, configuration settings, and steps to reproduce the issue.
