Vehicles despawn after disconnect

I use

function car()

local x, y, z = 801.07495117188,-3011.3627929688,-39.411521911621
local myPed = GetPlayerPed(-1)
local player = PlayerId()

local vehicle = GetHashKey('adder')

    RequestModel(vehicle)

    while not HasModelLoaded(vehicle) do
    Wait(1)
    end

local spawned_car = CreateVehicle(vehicle, x, y, z, 78.53, true, false)

    SetVehicleOnGroundProperly(spawned_car)
    SetVehicleNumberPlateText(spawned_car, "TEST")
	SetEntityAsMissionEntity(spawned_car, true, true ) 
    SetVehicleHasBeenOwnedByPlayer(spawned_car, true)
	FreezeEntityPosition(spawned_car, true)
	SetVehicleDoorsLocked(spawned_car, 2)

local id = NetworkGetNetworkIdFromEntity(spawned_car)
    SetNetworkIdCanMigrate(id, true)

end

What could be the problem?

If you’re the only one on the server, then it will de-spawn because the server doesn’t keep track of any entities.
Also, if other players are online, but they’re too far away, then it will de-spawn the vehicle.

1 Like

Is it possible to spawn a car as a texture so that it never disappears?

what…?