NPC freeze won't work

When Ped spawn it start instantly walking away and i have tried everything to fix it
Client:

local isMenuOpen = false
local p

function CreateMenu()
    isMenuOpen = true

    lib.registerContext({
        id = "mm:scubamenu",
        title = Config.Locales["MenuTitle"],
        canClose = true,
        options = {
            {
                title = Config.Locales["Rent"]
            }
        },
        onExit = function ()
            isMenuOpen = false  
        end
    })
    lib.showContext("mm:scubamenu")
end

function CreatePedForBlip()
    local pedModel = GetHashKey(Config.NpcConfig.PedModel)

    RequestModel(pedModel)
    while not HasModelLoaded(pedModel) do
        Citizen.Wait(0)
    end
    CreatePedA(pedModel)
    SetModelAsNoLongerNeeded(pedModel)
end

function CreatePedA(pedModel)
    local pedCoords = vector3(Config.NpcConfig.Coords.x, Config.NpcConfig.Coords.y, Config.NpcConfig.Coords.z)
    local heading = Config.NpcConfig.Heading

    p = CreatePed(0, pedModel, pedCoords.x, pedCoords.y, pedCoords.z, heading, true, false)

    FreezeEntityPosition(p, true)
    SetEntityInvincible(p, true)
    SetBlockingOfNonTemporaryEvents(p, true)
    ClearPedTasks(p)

    if Config.UsesOxTarget then
        exports["ox_target"]:addLocalEntity(p, {
            name = "mm:scubauiopentarget",
            label = Config.Locales["OxTargetLabel"],
            distance = 1,
            onSelect = function (data)
                CreateMenu()
            end
        })
    end
end

function CreateBlip()
    local Blip = AddBlipForCoord(Config.NpcConfig.Coords.x, Config.NpcConfig.Coords.y, Config.NpcConfig.Coords.z)
    SetBlipSprite(Blip, Config.BlipSettings.Sprite)
    BeginTextCommandSetBlipName("STRING")
    AddTextComponentString(Config.BlipSettings.BlipName)
    EndTextCommandSetBlipName(Blip)
end

function StartUp()
    --CreatePedForBlip()
    CreateBlip()
end

AddEventHandler("onResourceStart", StartUp)
Citizen.CreateThread(CreatePedForBlip)

Try without ClearPedTasks, or try give the ped an idle task like how qb-shops does it.

ShopPed[k] = CreatePed(0, current, v['coords'].x, v['coords'].y, v['coords'].z - 1, v['coords'].w, false, false)
TaskStartScenarioInPlace(ShopPed[k], v['scenario'], 0, true)
FreezeEntityPosition(ShopPed[k], true)
SetEntityInvincible(ShopPed[k], true)
SetBlockingOfNonTemporaryEvents(ShopPed[k], true)

Remove SetModelAsNoLongerNeeded(pedModel) from here and try

Still starts walking

Same here