My addon ped is not visible on the first load

Hello, I have a code that spawns a specific ped at a specific location on my local server on the first attempt, but it spawns my ped as invisible. When I spawn it myself in-game by typing it in, my ped works fine. Btw my ped is a custom ped I made myself.

Hi there, post your code here and someone might be able to point out where the mistake is.

local spawnPoint = {
    x = -1208.59,
    y = -1135.3,
    z = 7.7,
    heading = 90.0,
    model = "luci" --  ped model name
}

Citizen.CreateThread(function()
    exports.spawnmanager:setAutoSpawn(false)

    exports.spawnmanager:setAutoSpawnCallback(function()
        -- Spawn delay (for sync)
        Citizen.Wait(3500)

        exports.spawnmanager:spawnPlayer(spawnPoint, function()
            -- force Spawn
            Citizen.CreateThread(function()
                local model = GetHashKey(spawnPoint.model)

                RequestModel(model)
                while not HasModelLoaded(model) do
                    Citizen.Wait(0)
                end

                SetPlayerModel(PlayerId(), model)
                SetModelAsNoLongerNeeded(model)

                local ped = PlayerPedId()
                SetEntityCoords(ped, spawnPoint.x, spawnPoint.y, spawnPoint.z, false, false, false, true)
                SetEntityHeading(ped, spawnPoint.heading)
                SetEntityVisible(ped, true) 
            end)
        end)
    end)

    exports.spawnmanager:forceRespawn()
end)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.