Creating a command and pedagressive

Hello guys, this is my first topic, I’m new to programing and to fivem and to GTA V.
But I’m doing well so far…

The problem is, I’m trying to create a command where a ped is spawned with guns and agressive to players on sight.
Tried everything, this is my latest try…
Client
RegisterNetEvent(“esx:createped”)
AddEventHandler(
“esx:createped”,
function(model)
model = (tonumber(model) ~= nil and tonumber(model) or GetHashKey(model))
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
local forward = GetEntityForwardVector(playerPed)
local x, y, z = table.unpack(coords + forward * 1.0)

	Citizen.CreateThread(
		function()
			RequestModel(model)
			CreatePed(5, model, x, y, z, 0.0, true, false)
			GiveWeaponToPed(npc, GetHashKey("WEAPON_CARBINERIFFLE"), 250, true, false)
			GiveWeaponToPed(npc, GetHashKey("WEAPON_PISTOL"), 250, true, false)
			SetCurrentPedWeapon(npc, GetHashKey("WEAPON_PISTOL"), true)
			
			while not HasModelLoaded(model) do
				Citizen.Wait(1)
			end

			
		end
	)
	Citizen.CreateThread(function()
		while true do
			Citizen.Wait(5000)
	
				SetRelationshipBetweenGroups(5, GetHashKey('PLAYER'), GetHashKey(army)) -- could be removed
				SetRelationshipBetweenGroups(5, GetHashKey(army), GetHashKey('PLAYER'))
			
		end
	end)
end

)

Server
TriggerEvent(‘es:addGroupCommand’, ‘createped’, ‘admin’, function(source, args, user)

TriggerClientEvent(‘esx:createped’, source, args[1])

end, function(source, args, user)

TriggerClientEvent(‘chat:addMessage’, source, { args = { ‘^1SYSTEM’, ‘Insufficient Permissions.’ } })

end, {help = (‘spawn_ped’), params = {{name = “name”, help = (‘spawn_ped_param’)}}})

So if someone got something to help me, I would be very gratefull