Falling through the map in FiveM: collisions not loading, how to fix
Players fall through the map on spawn or teleport? Fix late collisions: missing .ybn files, too much streaming, RequestCollisionAtCoord and HasCollisionLoadedAroundEntity.
The symptom: you spawn, teleport or walk into a custom interior and you fall through the floor, sometimes into the sea or the void under the map, or you fall for a few seconds on connect before you land. The cause is one thing: the game draws the world before it has loaded the collision that makes it solid. Here is how to fix it in the files and in your scripts.
Why it happens
Collision data (.ybn files) is streamed like models. The game loads it around the player, and it takes time. When a script moves the player far away at once, or a player spawns on a busy server, the player can be placed before the floor exists. Gravity wins and the player falls.
There are four usual causes:
- A custom map has no collision, or it is not streamed.
- The server streams too much, so every load is slow.
- A script teleports without waiting for the collision.
- The connection is slow, so the resource files arrive late for a player who joins.
Cause 1: missing .ybn in a custom map
If you fall through only inside one MLO or one map, look at its resource first:
my_mlo/
fxmanifest.lua
stream/
my_mlo.ymap
my_mlo.ytyp
my_mlo.ybn <- the collisions- The
.ybnfiles must be insidestream. A.ybnoutside it is never sent to the players. - A pack for several parts of a building can have several
.ybnfiles. Make sure all of them came across when you copied the folder. - If the pack has no
.ybnat all, the author did not make the collisions, and a map editing tool is needed to build them. Contact the author or choose another map. - Check the resource is started and the manifest has
this_is_a_map 'yes'. See how to install an MLO for the full layout.
Cause 2: streaming too much
Every player downloads and loads the streamed files of your resources. Very large textures, too many addon cars, clothes, peds and maps use the streaming budget, and collisions then load late because they queue behind the heavy files.
Signs are a slow join, textures that pop in late, and warnings in the console. Shrink and remove what you do not need: oversized assets and texture loss shows how. A lighter server loads collisions faster for everybody.
Tip: after you removed assets, clear your own client cache and test again, since an old cache can hide the gain. See clear the FiveM cache.
Cause 3: a script that does not wait
This is the most common cause on teleports, respawns and spawn selectors. The fix is to freeze the player, request the collision, wait until it loads, and only then let the player go.
local function teleportSafe(coords)
local ped = PlayerPedId()
FreezeEntityPosition(ped, true)
SetEntityCoordsNoOffset(ped, coords.x, coords.y, coords.z, false, false, false)
RequestCollisionAtCoord(coords.x, coords.y, coords.z)
local timeout = GetGameTimer() + 5000
while not HasCollisionLoadedAroundEntity(ped) and GetGameTimer() < timeout do
RequestCollisionAtCoord(coords.x, coords.y, coords.z)
Wait(0)
end
FreezeEntityPosition(ped, false)
endWhat each part does:
FreezeEntityPositionholds the player still, so gravity cannot act while you wait.RequestCollisionAtCoordtells the game to start loading the collision at those coordinates. Call it each frame while you wait.HasCollisionLoadedAroundEntityreturns true when the collision around the ped is there.- The timeout stops an endless loop if the area never loads, for example when the map has no collision at all.
Use the same pattern when a player spawns after character selection, and for vehicles: freeze the vehicle with FreezeEntityPosition(vehicle, true) and wait on HasCollisionLoadedAroundEntity(vehicle).
Cause 4: spawning too early on connect
On connect, the first spawn can happen before the area is ready. Spawn and multicharacter scripts that do not wait are the usual reason. If the player is invisible and frozen during the first seconds and then falls, check your spawn script for the pattern above. For a join that hangs on the loading screen, see players stuck on the loading screen.
If the problem occurs only for players with slow connections, the files are still being downloaded when the player is placed. Keeping the streamed files small is the best help, and a loading or a fade screen that holds the player until the check above is true avoids most of the visible falls.
Debugging checklist for one place
- Does it happen to everyone, or only to some players? Everyone points to the map files, some players to cache or speed.
- Does it happen only at one place? Then it is a map resource with no collision there.
- Stop that map resource and try again. If you no longer fall, the map lacks collision. If a base game place also makes you fall, the problem is the load, not the map.
- Does it happen only right after a teleport? The script needs the wait loop above.
When two maps overlap
A collision can also be missing when one map removes the base game objects and the other map does not put its own collision in their place. See map conflicts.
Checklist
| Symptom | Fix |
|---|---|
| Fall inside one custom map | Add the .ybn files to its stream folder |
| Fall after a teleport | Freeze, RequestCollisionAtCoord, wait for HasCollisionLoadedAroundEntity |
| Fall on connect | Make the spawn script wait for the collision before it unfreezes |
| Everything loads slowly | Reduce streamed asset size and count |
| Only some players fall | Clear their cache, and check their connection |
| Endless wait loop | Add a timeout so the loop ends even if the area never loads |
Quick answers
Why do I fall through the map when I teleport?
The game has not loaded the collision around the new position yet, so there is no floor to stand on. Request the collision at the destination and wait until it is loaded before you unfreeze the player.
Which native waits for collisions to load?
HasCollisionLoadedAroundEntity(entity) returns true when the collision around that entity is loaded. Call RequestCollisionAtCoord(x, y, z) first so the game starts loading it.
Why does it happen on a custom map only?
The map has no .ybn collision files, or they are in the wrong folder, or they are missing from the stream. The visible model is there but nothing solid is.
Scripts that skip this problem
Advanced BoostingTablet-driven vehicle boosting: contracts from class D to S+, crews and a live queue.View script →
Quest CreatorA visual editor for quests and NPC dialogues, built node by node in game.View script →
CCTV Security CamerasPlaceable cameras, a live multi-view tablet and printed evidence photos.View script →