# Routing buckets in FiveM: instances without a second server

> Build instances in FiveM with routing buckets: SetPlayerRoutingBucket, entity buckets, population and lockdown per bucket, and sending players back to zero.

Source: https://fam-tools.com/guides/fivem-routing-buckets · FAM Tools · published 2026-09-11 · updated 2026-09-11 · about 9 min

**Short answer.** On the server, move players with `SetPlayerRoutingBucket(src, bucket)` and entities with `SetEntityRoutingBucket(entity, bucket)`; read them with `GetPlayerRoutingBucket` / `GetEntityRoutingBucket`. Disable AI population in a bucket with `SetRoutingBucketPopulationEnabled(bucket, false)` and set its entity lockdown with `SetRoutingBucketEntityLockdownMode`. Bucket 0 is the normal world — always return players there when they leave.

## Key points

- Bucket 0 = the shared world.
- Move both the player and anything they bring (their vehicle).
- Turn off population in instance buckets.
- Per-bucket entity lockdown is available.
- Always return players to 0 on exit and on disconnect logic.

Routing buckets split one server into separate worlds: players and entities in bucket 5 never see bucket 0. They are how apartments feel private, how character creation hides you from the city, and how one server runs several PvP arenas at once.

## Moving players and entities

*server.lua — a private apartment instance*

```lua
local function enterInstance(src, id)
    local bucket = 1000 + id
    SetRoutingBucketPopulationEnabled(bucket, false)
    SetRoutingBucketEntityLockdownMode(bucket, 'strict')
    SetPlayerRoutingBucket(src, bucket)
end

local function leaveInstance(src)
    SetPlayerRoutingBucket(src, 0)
end
```

Entities must be moved separately: a player who enters an instance in a car should have the car moved with `SetEntityRoutingBucket` too, or they arrive without it.

## Typical uses

| Use | Bucket plan |
| --- | --- |
| Character creation / multicharacter | One bucket per player while choosing |
| Apartments and houses | One bucket per property instance |
| PvP arenas | One bucket per match |
| Events | A dedicated bucket so the city is not affected |

## Gotchas

- Voice: whether players in different buckets hear each other depends on your voice resource — test it.
- Scripts that loop over “nearby players” on the client only see their own bucket — usually what you want.
- Server-created entities start in bucket 0 unless moved.
- Track who is in which bucket so a crash or disconnect does not leave data behind.

Buckets require OneSync — see [OneSync explained](https://fam-tools.com/guides/fivem-onesync-infinity). Server-side spawning: [server-side entities](https://pityus.net/guides/fivem-server-side-entities).

## Questions

### What is a routing bucket in FiveM?

A separate virtual world on the same server. Players and entities only see others in the same bucket.

### How do I put a player in an instance?

On the server: `SetPlayerRoutingBucket(source, bucketId)`; return them with bucket 0.

### How do I stop traffic spawning in an instance?

`SetRoutingBucketPopulationEnabled(bucketId, false)`.

### Why did my car not come with me into the instance?

Entities are moved separately with `SetEntityRoutingBucket`.

## Related

- https://fam-tools.com/guides/fivem-onesync-infinity
- https://fam-tools.com/guides/fivem-entity-limits-cleanup
- https://fam-tools.com/guides/fivem-player-identifiers
- https://fam-tools.com/guides/fivem-desync-network-issues
