> For the complete documentation index, see [llms.txt](https://gley.gitbook.io/mobile-traffic-system/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gley.gitbook.io/mobile-traffic-system/complete-api/getvehiclecomponent.md).

# GetVehicleComponent

### Description

Gets the Vehicle Component from the vehicle with the index passed as a parameter.

### Declaration&#x20;

```csharp
public static VehicleComponent GetVehicleComponent(int vehicleIndex)
```

### Parameters

<table><thead><tr><th width="188">Name</th><th>Description</th></tr></thead><tbody><tr><td><strong>vehicleIndex</strong></td><td>The index of the vehicle to get the component from.</td></tr></tbody></table>

### Returns

**VehicleComponent** - the component from the vehicle with the index passed as a parameter.

### Example

```csharp
using Gley.TrafficSystem;
using UnityEngine;

public class Test : MonoBehaviour
{
    //a reference to vehicle pool and player assigned in inspector
    public VehiclePool vehiclePool;
    public Transform player;

    void Start()
    {
        API.Initialize(player, 20, vehiclePool);
    }

    public void ExcludeVehicle()
    {
        //get the vehicle component from the vehicle with index 0 and debug its max speed
        VehicleComponent component = API.GetVehicleComponent(0);
        if (component != null)
        {
            Debug.Log(component.GetMaxSpeed());
        }
    }
}
```
