local bodyguard = {}
bodyguard.peds = {}
bodyguard.howMany = 2
function bodyguard.unload()
	for k,guard in pairs(bodyguard.peds) do
		if( guard ~= nil) then
			PED.DELETE_PED(guard)
			bodyguard.peds[k] = nil
		end
	end
end
function bodyguard.tick()
	if(get_key_pressed(101)) then 
		local zombieSkinID = GAMEPLAY.GET_HASH_KEY("u_m_y_zombie_01")
		local playerPed = PLAYER.PLAYER_PED_ID()
		local player = PLAYER.GET_PLAYER_PED(playerPed)
		local playerID = PLAYER.PLAYER_ID()
		local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)
		local playerPosition = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, 0.0, 5.0, 0.0)
		local playerGroup = PED.GET_PED_GROUP_INDEX(playerPed)
		bodyguard.unload()
		STREAMING.REQUEST_MODEL(zombieSkinID)
		while(not STREAMING.HAS_MODEL_LOADED(zombieSkinID)) do
				wait(50)
		end
		for i = 0 ,bodyguard.howMany,1 do
			bodyguard.peds[i] = PED.CREATE_PED( 26,zombieSkinID,playerPosition.x, playerPosition.y, playerPosition.z,1,false,true)	
			PED.SET_PED_CAN_SWITCH_WEAPON(bodyguard.peds[i],true)
			WEAPON.GIVE_DELAYED_WEAPON_TO_PED(bodyguard.peds[i], GAMEPLAY.GET_HASH_KEY("WEAPON_RAILGUN"), 1000, false)
			WEAPON.GIVE_DELAYED_WEAPON_TO_PED(bodyguard.peds[i], GAMEPLAY.GET_HASH_KEY("WEAPON_PISTOL"), 1000, false)
			PED.SET_PED_AS_GROUP_MEMBER(bodyguard.peds[i], playerGroup)
		end
		STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(zombieSkinID)
	end
end

return bodyguard