> For the complete documentation index, see [llms.txt](https://gley.gitbook.io/mobile-pedestrian-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-pedestrian-system/complete-api/dontremovepedestrian.md). Agents can also search and read this documentation through its [MCP server](https://gley.gitbook.io/mobile-pedestrian-system/~gitbook/mcp).

# DontRemovePedestrian

### Description

Prevents the removal of a pedestrian at the specified index by the pooling system. The pedestrian will never be respawned unless the marking is removed or it is manually removed.

### Declaration

```csharp
public static void DontRemovePedestrian(int pedestrianIndex, bool dontRemove)
```

### Parameters

<table><thead><tr><th width="261">Name</th><th>Description</th></tr></thead><tbody><tr><td><strong>pedestrianIndex</strong></td><td>The index of the pedestrian.</td></tr><tr><td><strong>dontRemove</strong></td><td>A value indicating whether the pedestrian should not be removed.</td></tr></tbody></table>

### Example

```csharp
using Gley.PedestrianSystem;
using UnityEngine;
public class Test : MonoBehaviour
{
    // A reference to the pedestrian pool and player assigned in the inspector.
    public PedestrianPool PedestrianPool;
    public Transform Player;

    void Start()
    {
        API.Initialize(Player, 1, PedestrianPool);
    }

    // Used for demonstration purposes.
    private void Update()
    {
        // Prevent pedestrians from being removed.
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            API.DontRemovePedestrian(0, true);
        }

        // Allow pedestrians to be removed.
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            API.DontRemovePedestrian(0, false);
        }
    }
}
```
