Need some help with model NPc changer

i got some for serverside and some for client side want this as a standalone thing but getting problems by puting it in one script it wount load

server side i used :

TriggerEvent('es:addGroupCommand', 'npc', 'admin' , function(source, args, user)
TriggerClientEvent(args)
end)

client side i user this

RegisterCommand('npc', function(source, args)
    local model = GetHashKey(args[1])
    RequestModel(model)
    while not HasModelLoaded(model) do
    Citizen.Wait(0)
    end
    SetPlayerModel(PlayerId(), model)
end)

maybe someone can help me

Are you wanting to change your model, another players model or an NPCs model?

i want to change my own model

Here’s an example for you.

client.lua

-- Functions
local function LoadPlayerModel(model)
    RequestModel(model)
    while not HasModelLoaded(model) do
		Wait(0)
    end
end

-- Commands
RegisterCommand('npc', function(source, args)
	local ped = PlayerPedId()
    local model = GetHashKey(args[1])
    SetEntityInvincible(ped, true)
    if IsModelInCdimage(model) and IsModelValid(model) then
        LoadPlayerModel(model)
        SetPlayerModel(PlayerId(), model)
        if isPedAllowedRandom(args[1]) then
            SetPedRandomComponentVariation(ped, true)
        end
		SetModelAsNoLongerNeeded(model)
	end
	SetEntityInvincible(ped, false)
end)